Skip to content

Commit fa73855

Browse files
authored
Log video info at the start of encode (#629)
1 parent 7610b5c commit fa73855

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

av1an-core/src/lib.rs

+13
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,19 @@ impl Input {
145145
})
146146
}
147147

148+
pub fn pixel_format(&self) -> anyhow::Result<String> {
149+
const FAIL_MSG: &str = "Failed to get resolution for input video";
150+
Ok(match self {
151+
Input::VapourSynth(video) => {
152+
crate::vapoursynth::pixel_format(video).map_err(|_| anyhow::anyhow!(FAIL_MSG))?
153+
}
154+
Input::Video(video) => {
155+
let fmt = crate::ffmpeg::get_pixel_format(video).map_err(|_| anyhow::anyhow!(FAIL_MSG))?;
156+
format!("{:?}", fmt)
157+
}
158+
})
159+
}
160+
148161
pub fn transfer_function(&self) -> anyhow::Result<TransferFunction> {
149162
const FAIL_MSG: &str = "Failed to get transfer characteristics for input video";
150163
Ok(match self {

av1an-core/src/settings.rs

+17-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use crate::broker::{Broker, EncoderCrash};
2525
use crate::chunk::Chunk;
2626
use crate::concat::{self, ConcatMethod};
2727
use crate::ffmpeg::{compose_ffmpeg_pipe, num_frames};
28-
use crate::grain::create_film_grain_file;
28+
use crate::grain::{create_film_grain_file, TransferFunction};
2929
use crate::parse::valid_params;
3030
use crate::progress_bar::{
3131
finish_progress_bar, inc_bar, inc_mp_bar, init_multi_progress_bar, init_progress_bar,
@@ -1085,6 +1085,22 @@ properly into a mkv file. Specify mkvmerge as the concatenation method by settin
10851085
None
10861086
};
10871087

1088+
let res = self.input.resolution()?;
1089+
let fps = self.input.frame_rate()?;
1090+
let format = self.input.pixel_format()?;
1091+
let tfc = self.input.transfer_function()?;
1092+
info!(
1093+
"Input: {}x{} @ {:.3} fps, {}, {}",
1094+
res.0,
1095+
res.1,
1096+
fps,
1097+
format,
1098+
match tfc {
1099+
TransferFunction::SMPTE2084 => "HDR",
1100+
TransferFunction::BT1886 => "SDR",
1101+
}
1102+
);
1103+
10881104
let splits = self.split_routine()?;
10891105

10901106
if self.sc_only {

av1an-core/src/vapoursynth.rs

+16
Original file line numberDiff line numberDiff line change
@@ -269,3 +269,19 @@ pub fn transfer_characteristics(source: &Path) -> anyhow::Result<u8> {
269269

270270
get_transfer(&mut environment)
271271
}
272+
273+
pub fn pixel_format(source: &Path) -> anyhow::Result<String> {
274+
// Create a new VSScript environment.
275+
let mut environment = Environment::new().unwrap();
276+
277+
// Evaluate the script.
278+
environment
279+
.eval_file(source, EvalFlags::SetWorkingDir)
280+
.unwrap();
281+
282+
let info = get_clip_info(&mut environment);
283+
match info.format {
284+
Property::Variable => bail!("Variable pixel format not supported"),
285+
Property::Constant(x) => Ok(x.name().to_string()),
286+
}
287+
}

0 commit comments

Comments
 (0)