ffmpeg - Skip process if output already exists

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.


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.

Tags:

Ffmpeg