Can I make ffmpeg stop if integrity check encounters an error?
In an option:
-xerror
The command line option is documented as doing exactly what you want.
Add the option and ffmpeg will exit on a stream error (also setting exit value to 1) from:
ffmpeg -h full | grep xerror .... -xerror error exit on error
I've already wondered about this myself, and ffmpeg
doesn't provide an easy way to do that. Based on the feedback I got on the FFmpeg mailing list, you can use the global option
-err_detect explode
This option doesn't appear to work in all cases though. See ffmpeg -h full
for the option list:
-err_detect <flags> .D.... set error detection flags
The values are as follows:
Possible values:
crccheck
: verify embedded CRCs
bitstream
: detect bitstream specification deviations
buffer
: detect improper bitstream length
explode
: abort decoding on minor error detection
ignore_err
: ignore decoding errors, and continue decoding. This is useful if you want to analyze the content of a video and thus want everything to be decoded no matter what. This option will not result in a video that is pleasing to watch in case of errors.
careful
: consider things that violate the spec and have not been seen in the wild as errors
compliant
: consider all spec non compliancies as errors
aggressive
: consider things that a sane encoder should not do as an error