ffplay_preview/
ffplay_preview.rsuse std::{
io::{Read, Write},
process::{Command, Stdio},
};
use ffmpeg_sidecar::command::FfmpegCommand;
fn main() {
let mut ffmpeg = FfmpegCommand::new()
.realtime()
.format("lavfi")
.input("testsrc=size=1920x1080:rate=60")
.codec_video("rawvideo")
.format("avi")
.output("-")
.spawn()
.unwrap();
let mut ffplay = Command::new("ffplay")
.args("-i -".split(' '))
.stdin(Stdio::piped())
.spawn()
.unwrap();
let mut ffmpeg_stdout = ffmpeg.take_stdout().unwrap();
let mut ffplay_stdin = ffplay.stdin.take().unwrap();
let buf = &mut [0u8; 4096];
loop {
let n = ffmpeg_stdout.read(buf).unwrap();
if n == 0 {
break;
}
ffplay_stdin.write_all(&buf[..n]).unwrap();
}
}