Skip to content

Commit b8272ae

Browse files
authored
Don't panic if ffmpeg fails to count frames (#634)
* Don't panic if ffmpeg fails to count frames * Fix formatting
1 parent fe585ac commit b8272ae

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

av1an-core/src/settings.rs

+15-7
Original file line numberDiff line numberDiff line change
@@ -427,20 +427,28 @@ impl EncodeArgs {
427427
}
428428

429429
if current_pass == passes {
430-
let encoded_frames = num_frames(chunk.output().as_ref()).unwrap();
430+
let encoded_frames = num_frames(chunk.output().as_ref());
431+
432+
let err_str = match encoded_frames {
433+
Ok(encoded_frames) if encoded_frames != chunk.frames => Some(format!(
434+
"FRAME MISMATCH: chunk {}: {}/{} (actual/expected frames)",
435+
chunk.index, encoded_frames, chunk.frames
436+
)),
437+
Err(error) => Some(format!(
438+
"FAILED TO COUNT FRAMES: chunk {}: {}",
439+
chunk.index, error
440+
)),
441+
_ => None,
442+
};
431443

432-
if encoded_frames != chunk.frames {
444+
if let Some(err_str) = err_str {
433445
return Err((
434446
EncoderCrash {
435447
exit_status: enc_output.status,
436448
source_pipe_stderr: source_pipe_stderr.into(),
437449
ffmpeg_pipe_stderr: ffmpeg_pipe_stderr.map(Into::into),
438450
stderr: enc_stderr.into(),
439-
stdout: format!(
440-
"FRAME MISMATCH: chunk {}: {}/{} (actual/expected frames)",
441-
chunk.index, encoded_frames, chunk.frames
442-
)
443-
.into(),
451+
stdout: err_str.into(),
444452
},
445453
frame,
446454
));

0 commit comments

Comments
 (0)