22

I'm running a batch script to convert video file in Python but it can happen that the output file already exists, so is there an option to avoid ffmpeg asking me what to do if output already exists? I want it to automatically skip the process.

37

From the ffmpeg documentation:

-n (global)
Do not overwrite output files, and exit immediately if a specified output file already exists.

Usage:

$ ffmpeg -n -i input output.mp4
  …
  File 'output.mp4' already exists. Exiting.
  • -n is a global option. Global options should be specified first.
  • The opposite option is -y which will automatically overwrite the output without asking.

Note: There is a bug that causes -n to not work in some cases, such as with the tee and image muxers. See bug report #8492: tee muxer silently overwrites output files. Until this bug is fixed it is recommended to test first or use your scripting language to check if the output exists.

2
  • I ran ffmpeg -n -i input.vid output/%06d.png and it clobbered the pre-existing output files. – Arnon Weinberg Oct 5 '20 at 4:50
  • 1
    Looks like this bug is already mentioned (in comments) here. – Arnon Weinberg Oct 5 '20 at 21:17
3

Ideally your script should check for the existence of the input and output files prior to you calling ffmpeg to do its (potentially) dangerous operation. By dangerous I mean overwrite existing files...

Once you have ascertained whether the output already exists your script can move on to the next file for processing.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.