don't push videos
This commit is contained in:
parent
fdb3de89a9
commit
dcfaf41a31
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
/target
|
||||
/.vscode
|
||||
*.png
|
||||
*.mkv
|
||||
|
@ -8,6 +8,7 @@ use ffmpeg::media::Type;
|
||||
use ffmpeg::software::scaling::{context::Context, flag::Flags};
|
||||
use ffmpeg::util::frame::video::Video;
|
||||
use std::path::Path;
|
||||
use std::time::Instant;
|
||||
mod out;
|
||||
|
||||
fn main() -> Result<(), Error> {
|
||||
@ -16,13 +17,14 @@ fn main() -> Result<(), Error> {
|
||||
ffmpeg::init()?;
|
||||
|
||||
// read the input file
|
||||
if let Ok(mut ictx) = input(&Path::new("rgb.png")) {
|
||||
if let Ok(mut ictx) = input(&Path::new("output.mkv")) {
|
||||
|
||||
let input = ictx
|
||||
.streams()
|
||||
.best(Type::Video)
|
||||
.ok_or(ffmpeg::Error::StreamNotFound)?;
|
||||
let video_stream_index = input.index();
|
||||
let fps = input.avg_frame_rate();
|
||||
|
||||
let context_decoder = ffmpeg::codec::context::Context::from_parameters(input.parameters())?;
|
||||
// Ctx's video decoder
|
||||
@ -50,7 +52,7 @@ fn main() -> Result<(), Error> {
|
||||
|
||||
// test::print_raw(&rgb_frame.data(0));
|
||||
// test::print_square(&rgb_frame.data(0), rgb_frame.width() as usize);
|
||||
out::print_square(&rgb_frame, out::LinesFormat::RightLeft);
|
||||
out::print_square(&rgb_frame, out::LinesFormat::RightLeft, video_stream_index);
|
||||
// test::small_matrix();
|
||||
}
|
||||
Ok(())
|
||||
@ -61,6 +63,9 @@ fn main() -> Result<(), Error> {
|
||||
// Is this for multiple video streams?
|
||||
if stream.index() == video_stream_index {
|
||||
decoder.send_packet(&packet)?;
|
||||
|
||||
let now = Instant::now();
|
||||
|
||||
receive_and_process_decoded_frames(&mut decoder)?;
|
||||
}
|
||||
}
|
||||
|
10
src/out.rs
10
src/out.rs
@ -14,12 +14,12 @@ pub enum LinesFormat {
|
||||
}
|
||||
|
||||
/// Must use square images
|
||||
pub fn print_square(frame: &ffmpeg::frame::Video, lines_format: LinesFormat) {
|
||||
pub fn print_square(frame: &ffmpeg::frame::Video, lines_format: LinesFormat, video_index: usize) {
|
||||
if frame.format() != Pixel::RGB24 { panic!("Must use Pixel::RGB24"); }
|
||||
if frame.width() != frame.height() { panic!("Must be 1:1 aspect ratio"); }
|
||||
// Not sure if you can stack multiple frames on top of each other or what,
|
||||
// but we just want the first one.
|
||||
let z = 0;
|
||||
|
||||
// This will panic if it's out of bounds.
|
||||
let z = video_index;
|
||||
|
||||
let size = frame.width() as usize;
|
||||
// How many bytes per pixel RGBA
|
||||
@ -71,4 +71,4 @@ fn reverse(raw: & mut [u8]) {
|
||||
.collect::<Vec<u8>>();
|
||||
|
||||
x.iter().enumerate().for_each(|f| raw[f.0] = *f.1);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user