Can I make ffmpeg stop if integrity check encounters an error?

9

2

Is there a way to stop ffmpeg from processing if an error was encountered? I'm using ffmpeg to check video integrity by using:

ffmpeg -v error -i file.avi -f null - 2>error.log

However, I'd like to expand on it to stop the process as soon as an error is identified.

Kate

Posted 2013-04-26T17:26:22.593

Reputation: 225

Answers

8

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

slhck

Posted 2013-04-26T17:26:22.593

Reputation: 182 472

Thanks! I will give that option a go, some error capturing is better then nothing :) – Kate – 2013-04-30T15:24:43.487

10

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

Michelle Sullivan

Posted 2013-04-26T17:26:22.593

Reputation: 101

2Thanks a lot, that's exactly what i want, I believe this is the answer. not the slhck's answer. – pylover – 2016-04-13T07:43:27.220