Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log video info at the start of encode #629

Merged
merged 1 commit into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions av1an-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,19 @@ impl Input {
})
}

pub fn pixel_format(&self) -> anyhow::Result<String> {
const FAIL_MSG: &str = "Failed to get resolution for input video";
Ok(match self {
Input::VapourSynth(video) => {
crate::vapoursynth::pixel_format(video).map_err(|_| anyhow::anyhow!(FAIL_MSG))?
}
Input::Video(video) => {
let fmt = crate::ffmpeg::get_pixel_format(video).map_err(|_| anyhow::anyhow!(FAIL_MSG))?;
format!("{:?}", fmt)
}
})
}

pub fn transfer_function(&self) -> anyhow::Result<TransferFunction> {
const FAIL_MSG: &str = "Failed to get transfer characteristics for input video";
Ok(match self {
Expand Down
18 changes: 17 additions & 1 deletion av1an-core/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::broker::{Broker, EncoderCrash};
use crate::chunk::Chunk;
use crate::concat::{self, ConcatMethod};
use crate::ffmpeg::{compose_ffmpeg_pipe, num_frames};
use crate::grain::create_film_grain_file;
use crate::grain::{create_film_grain_file, TransferFunction};
use crate::parse::valid_params;
use crate::progress_bar::{
finish_progress_bar, inc_bar, inc_mp_bar, init_multi_progress_bar, init_progress_bar,
Expand Down Expand Up @@ -1085,6 +1085,22 @@ properly into a mkv file. Specify mkvmerge as the concatenation method by settin
None
};

let res = self.input.resolution()?;
let fps = self.input.frame_rate()?;
let format = self.input.pixel_format()?;
let tfc = self.input.transfer_function()?;
info!(
"Input: {}x{} @ {:.3} fps, {}, {}",
res.0,
res.1,
fps,
format,
match tfc {
TransferFunction::SMPTE2084 => "HDR",
TransferFunction::BT1886 => "SDR",
}
);

let splits = self.split_routine()?;

if self.sc_only {
Expand Down
16 changes: 16 additions & 0 deletions av1an-core/src/vapoursynth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,19 @@ pub fn transfer_characteristics(source: &Path) -> anyhow::Result<u8> {

get_transfer(&mut environment)
}

pub fn pixel_format(source: &Path) -> anyhow::Result<String> {
// Create a new VSScript environment.
let mut environment = Environment::new().unwrap();

// Evaluate the script.
environment
.eval_file(source, EvalFlags::SetWorkingDir)
.unwrap();

let info = get_clip_info(&mut environment);
match info.format {
Property::Variable => bail!("Variable pixel format not supported"),
Property::Constant(x) => Ok(x.name().to_string()),
}
}