mod ivf;
use self::ivf::IvfMuxer;
mod y4m;
pub use self::y4m::write_y4m_frame;
use rav1e::prelude::*;
use std::ffi::OsStr;
use std::io;
use std::path::Path;
use crate::error::*;
pub trait Muxer: Send {
fn write_header(
&mut self, width: usize, height: usize, framerate_num: usize,
framerate_den: usize,
);
fn write_frame(&mut self, pts: u64, data: &[u8], frame_type: FrameType);
fn flush(&mut self) -> io::Result<()>;
}
pub fn create_muxer(
path: &str, overwrite: bool,
) -> Result<Box<dyn Muxer + Send>, CliError> {
if !overwrite {
IvfMuxer::check_file(path)?;
}
if path == "-" {
return IvfMuxer::open(path);
}
let ext = Path::new(path)
.extension()
.and_then(OsStr::to_str)
.map(str::to_lowercase)
.unwrap_or_else(|| "ivf".into());
match &ext[..] {
"ivf" => IvfMuxer::open(path),
_e => {
panic!("{} is not a supported extension, please change to .ivf", ext);
}
}
}