[FFmpeg-user] feature proposal - avoid overwriting the input file

James Girotti james.girotti at gmail.com
Wed Oct 11 03:12:57 EEST 2017


On Tue, Oct 10, 2017 at 4:40 PM, Mikhail V <mikhailwas at gmail.com> wrote:

> Currently it is possible to delete the input file if I specify same
> filename in output,
> for example:
>
> ffmpeg -y -i input input
>

Aren't you specifying that with '-y' you want to "overwrite output file
without asking"


> or simply:
> ffmpeg -i input input
> (this will promt y/n)
>

I believe this is the default behavior for any output file that is present
whether it matches input or not (in my example both foo.mkv and bar.mkv
file present):

ffmpeg -i foo.mkv bar.mkv
Input #0, matroska,webm, from 'foo.mkv':
  Metadata:
    ENCODER         : Lavf57.71.100
  Duration: 01:00:30.05, start: 0.000000, bitrate: 5195 kb/s
    Stream #0:0: Video: h264 (Main), yuv420p(progressive), 1920x1080 [SAR
1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 1k tbn, 59.94 tbc (default)
    Metadata:
      ENCODER         : Lavc57.89.100 h264_nvenc
      DURATION        : 01:00:30.047000000
    Stream #0:1: Audio: aac (LC), 48000 Hz, 5.1, fltp (default)
    Metadata:
      ENCODER         : Lavc57.89.100 aac
      DURATION        : 01:00:30.021000000
File 'bar.mkv' already exists. Overwrite ? [y/N]


> So this will immideately destroy the input file.
> It did not happened with me often, but still happened a pair of times.
>

That is why almost never user '-y' and only if I am 100% certain it is
safe. Which in my case are FIFOs


> Was quite funny actually :) Funniest thing that I could not recover the
> file
> because it is same name.
>

That reminds me of when I accidentally did 'rm -rf /*'


>
> So, it would be nice if ffmpeg compare the output path with all input paths
> and exit with an error.
>

Is it possible for you to run your command without '-y' or if you're using
a script, then to compare your input and output before passing them to
ffmpeg?


More information about the ffmpeg-user mailing list