ffmpeg - Skip process if output already exists
--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Unforgiving Himalayas Looping
--
Chapters
00:00 Ffmpeg - Skip Process If Output Already Exists
00:21 Accepted Answer Score 47
01:11 Answer 2 Score 2
01:32 Thank you
--
Full question
https://superuser.com/questions/922866/f...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#ffmpeg
#avk47
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Unforgiving Himalayas Looping
--
Chapters
00:00 Ffmpeg - Skip Process If Output Already Exists
00:21 Accepted Answer Score 47
01:11 Answer 2 Score 2
01:32 Thank you
--
Full question
https://superuser.com/questions/922866/f...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#ffmpeg
#avk47
ACCEPTED ANSWER
Score 47
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.
ANSWER 2
Score 2
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.