readme
This commit is contained in:
parent
61b6adb5bb
commit
117c64a9a1
7
README.md
Normal file
7
README.md
Normal file
@ -0,0 +1,7 @@
|
||||
## Video Parser
|
||||
This takes a visual media input (photo / video / etc) and uses ffmpeg to read the rgb values then writes them to `stdout` as raw data. This can the be piped to [/dev/ttyACMx](https://github.com/Rushmore75/led_matrix) which will display them.
|
||||
To find the arduino you can run:
|
||||
```
|
||||
ls /dev/serial/by-id/ | grep arduino | xargs -I{} readlink /dev/serial/by-id/{}
|
||||
```
|
||||
which will output `../../ttyACMX` or simmilar. Then `/dev/ttyACMX` (for example) is your arduino.
|
22
src/test.rs
22
src/test.rs
@ -1,15 +1,5 @@
|
||||
use std::io::*;
|
||||
use std::io::{stdout, Write};
|
||||
use ffmpeg::format::Pixel;
|
||||
use rand::Rng;
|
||||
|
||||
#[inline]
|
||||
/// Assumes a square ig
|
||||
pub fn print_raw(buf: &[u8]) {
|
||||
let mut stdout = stdout();
|
||||
let mut lock = stdout.lock();
|
||||
lock.write(buf).unwrap();
|
||||
stdout.flush().unwrap();
|
||||
}
|
||||
|
||||
/// Must use square images
|
||||
// pub fn print_square(buf: &[u8], width_hight: usize, line) {
|
||||
@ -25,6 +15,10 @@ pub fn print_square(frame: &ffmpeg::frame::Video) {
|
||||
// How many bytes per pixel RGBA
|
||||
let linesize = unsafe { std::ptr::addr_of!((*frame.as_ptr()).linesize) };
|
||||
let step = (unsafe { *linesize })[z] as usize;
|
||||
|
||||
let mut stdout = stdout();
|
||||
let mut lock = stdout.lock();
|
||||
|
||||
// (Assuming square) Step thru buffer.
|
||||
for i in 0..size {
|
||||
let j = i*step;
|
||||
@ -34,7 +28,11 @@ pub fn print_square(frame: &ffmpeg::frame::Video) {
|
||||
let slice = &pre_slice[0..size*3];
|
||||
// let lol = &buf[j..j+step][0..size*3];
|
||||
|
||||
println!("{:?} || {}-{}", slice, j, j+step);
|
||||
// DEBUG
|
||||
// println!("{:?} || {}-{}", slice, j, j+step);
|
||||
// NORMAL
|
||||
lock.write(slice).unwrap();
|
||||
}
|
||||
stdout.flush().unwrap();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user