don't push videos
This commit is contained in:
parent
fdb3de89a9
commit
dcfaf41a31
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
/target
|
/target
|
||||||
/.vscode
|
/.vscode
|
||||||
*.png
|
*.png
|
||||||
|
*.mkv
|
||||||
|
@ -8,6 +8,7 @@ use ffmpeg::media::Type;
|
|||||||
use ffmpeg::software::scaling::{context::Context, flag::Flags};
|
use ffmpeg::software::scaling::{context::Context, flag::Flags};
|
||||||
use ffmpeg::util::frame::video::Video;
|
use ffmpeg::util::frame::video::Video;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
use std::time::Instant;
|
||||||
mod out;
|
mod out;
|
||||||
|
|
||||||
fn main() -> Result<(), Error> {
|
fn main() -> Result<(), Error> {
|
||||||
@ -16,13 +17,14 @@ fn main() -> Result<(), Error> {
|
|||||||
ffmpeg::init()?;
|
ffmpeg::init()?;
|
||||||
|
|
||||||
// read the input file
|
// 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
|
let input = ictx
|
||||||
.streams()
|
.streams()
|
||||||
.best(Type::Video)
|
.best(Type::Video)
|
||||||
.ok_or(ffmpeg::Error::StreamNotFound)?;
|
.ok_or(ffmpeg::Error::StreamNotFound)?;
|
||||||
let video_stream_index = input.index();
|
let video_stream_index = input.index();
|
||||||
|
let fps = input.avg_frame_rate();
|
||||||
|
|
||||||
let context_decoder = ffmpeg::codec::context::Context::from_parameters(input.parameters())?;
|
let context_decoder = ffmpeg::codec::context::Context::from_parameters(input.parameters())?;
|
||||||
// Ctx's video decoder
|
// Ctx's video decoder
|
||||||
@ -50,7 +52,7 @@ fn main() -> Result<(), Error> {
|
|||||||
|
|
||||||
// test::print_raw(&rgb_frame.data(0));
|
// test::print_raw(&rgb_frame.data(0));
|
||||||
// test::print_square(&rgb_frame.data(0), rgb_frame.width() as usize);
|
// 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();
|
// test::small_matrix();
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -61,6 +63,9 @@ fn main() -> Result<(), Error> {
|
|||||||
// Is this for multiple video streams?
|
// Is this for multiple video streams?
|
||||||
if stream.index() == video_stream_index {
|
if stream.index() == video_stream_index {
|
||||||
decoder.send_packet(&packet)?;
|
decoder.send_packet(&packet)?;
|
||||||
|
|
||||||
|
let now = Instant::now();
|
||||||
|
|
||||||
receive_and_process_decoded_frames(&mut decoder)?;
|
receive_and_process_decoded_frames(&mut decoder)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,12 +14,12 @@ pub enum LinesFormat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Must use square images
|
/// 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.format() != Pixel::RGB24 { panic!("Must use Pixel::RGB24"); }
|
||||||
if frame.width() != frame.height() { panic!("Must be 1:1 aspect ratio"); }
|
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.
|
// This will panic if it's out of bounds.
|
||||||
let z = 0;
|
let z = video_index;
|
||||||
|
|
||||||
let size = frame.width() as usize;
|
let size = frame.width() as usize;
|
||||||
// How many bytes per pixel RGBA
|
// How many bytes per pixel RGBA
|
||||||
|
Loading…
Reference in New Issue
Block a user