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

Don't panic if ffmpeg fails to count frames #634

Merged
merged 2 commits into from
Jun 5, 2022
Merged
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
22 changes: 15 additions & 7 deletions av1an-core/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,20 +427,28 @@ impl EncodeArgs {
}

if current_pass == passes {
let encoded_frames = num_frames(chunk.output().as_ref()).unwrap();
let encoded_frames = num_frames(chunk.output().as_ref());

let err_str = match encoded_frames {
Ok(encoded_frames) if encoded_frames != chunk.frames => Some(format!(
"FRAME MISMATCH: chunk {}: {}/{} (actual/expected frames)",
chunk.index, encoded_frames, chunk.frames
)),
Err(error) => Some(format!(
"FAILED TO COUNT FRAMES: chunk {}: {}",
chunk.index, error
)),
_ => None,
};

if encoded_frames != chunk.frames {
if let Some(err_str) = err_str {
return Err((
EncoderCrash {
exit_status: enc_output.status,
source_pipe_stderr: source_pipe_stderr.into(),
ffmpeg_pipe_stderr: ffmpeg_pipe_stderr.map(Into::into),
stderr: enc_stderr.into(),
stdout: format!(
"FRAME MISMATCH: chunk {}: {}/{} (actual/expected frames)",
chunk.index, encoded_frames, chunk.frames
)
.into(),
stdout: err_str.into(),
},
frame,
));
Expand Down