Opened 9 years ago

Closed 9 years ago

Last modified 6 years ago

#4655 closed defect (fixed)

Feature request: -y ought not to overwrite source file

Reported by: artofit Owned by:
Priority: normal Component: ffmpeg
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

If the output file is the source file, ffmpeg should not delete the source, but ought to exit.

ffmpeg -y -i preciousVideoGonnaBeDeleted.mp4 -c:v libx264 preciousVideoGonnaBeDeleted.mp4

F:\>ffmpeg -y -i preciousVideoGonnaBeDeleted.mp4 -c:v libx264 preciousVideoGonnaBeDeleted.mp4
ffmpeg version N-72805-g913685f Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.9.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fo
ntconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --ena
ble-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-lib
modplug --enable-libmfx --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libope
njpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libt
heora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --
enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-li
bxvid --enable-lzma --enable-decklink --enable-zlib
  libavutil      54. 27.100 / 54. 27.100
  libavcodec     56. 41.100 / 56. 41.100
  libavformat    56. 36.100 / 56. 36.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 16.101 /  5. 16.101
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.100 /  1.  2.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'preciousVideoGonnaBeDeleted.mp4':
  Metadata:
    major_brand     : MSNV
    minor_version   : 19595353
    compatible_brands: MSNVmp42isom
    creation_time   : 2015-06-20 13:11:27
  Duration: 00:00:31.53, start: 0.000000, bitrate: 8888 kb/s
    Stream #0:0(und): Video: mpeg4 (Advanced Coding Profile) (mp4v / 0x7634706D), yuv420p, 1280x720 [SAR 1:1 DAR
16:9], 8822 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 30k tbc (default)
    Metadata:
      creation_time   : 2015-06-20 13:11:27
      handler_name    : Video Media Handler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 24000 Hz, mono, fltp, 64 kb/s (default)
    Metadata:
      creation_time   : 2015-06-20 13:11:27
      handler_name    : Sound Media Handler
[libx264 @ 0000000002f3f9e0] using SAR=1/1
[libx264 @ 0000000002f3f9e0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0000000002f3f9e0] profile High, level 3.1
[libx264 @ 0000000002f3f9e0] 264 - core 146 r2538 121396c - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://
www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1
.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offse
t=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intr
a=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 sce
necut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1
.40 aq=1:1.00
Output #0, mp4, to 'preciousVideoGonnaBeDeleted.mp4':
  Metadata:
    major_brand     : MSNV
    minor_version   : 19595353
    compatible_brands: MSNVmp42isom
    encoder         : Lavf56.36.100
    Stream #0:0(und): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1-
-1, 29.97 fps, 30k tbn, 29.97 tbc (default)
    Metadata:
      creation_time   : 2015-06-20 13:11:27
      handler_name    : Video Media Handler
      encoder         : Lavc56.41.100 libx264
    Stream #0:1(und): Audio: aac (libvo_aacenc) ([64][0][0][0] / 0x0040), 24000 Hz, mono, s16, 128 kb/s (default)

    Metadata:
      creation_time   : 2015-06-20 13:11:27
      handler_name    : Sound Media Handler
      encoder         : Lavc56.41.100 libvo_aacenc
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg4 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (aac (native) -> aac (libvo_aacenc))
Press [q] to stop, [?] for help
[mpeg4 @ 00000000059e8820] I cbpc damaged at 78 6
[mpeg4 @ 00000000059e8820] Error at MB: 564
[mpeg4 @ 00000000059e8820] concealing 3091 DC, 3091 AC, 3091 MV errors in I frame
frame=   16 fps=0.0 q=-1.0 Lsize=     202kB time=00:00:00.48 bitrate=3392.8kbits/s
video:192kB audio:9kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.788445%
[libx264 @ 0000000002f3f9e0] frame I:1     Avg QP:24.69  size: 49146
[libx264 @ 0000000002f3f9e0] frame P:15    Avg QP:25.39  size:  9775
[libx264 @ 0000000002f3f9e0] mb I  I16..4:  8.7% 89.0%  2.3%
[libx264 @ 0000000002f3f9e0] mb P  I16..4:  0.3%  0.4%  0.0%  P16..4: 60.4%  8.0%  4.7%  0.0%  0.0%    skip:26.2%

[libx264 @ 0000000002f3f9e0] 8x8 transform intra:86.1% inter:88.1%
[libx264 @ 0000000002f3f9e0] coded y,uvDC,uvAC intra: 77.2% 93.2% 48.2% inter: 19.4% 43.2% 0.6%
[libx264 @ 0000000002f3f9e0] i16 v,h,dc,p: 11% 35%  6% 48%
[libx264 @ 0000000002f3f9e0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 31% 18%  3%  5%  5%  6%  5%  6%
[libx264 @ 0000000002f3f9e0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 17% 27%  9%  5% 11%  9% 12%  5%  5%
[libx264 @ 0000000002f3f9e0] i8c dc,h,v,p: 44% 25% 22%  9%
[libx264 @ 0000000002f3f9e0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0000000002f3f9e0] ref P L0: 77.8% 11.7%  8.4%  2.1%
[libx264 @ 0000000002f3f9e0] kb/s:2933.74

F:\>

Change History (7)

comment:1 by Carl Eugen Hoyos, 9 years ago

Component: undeterminedffmpeg
Keywords: delete overwrite removed
Version: unspecifiedgit-master

comment:2 by Carl Eugen Hoyos, 9 years ago

The following works as expected (and I wonder if it really makes sense to change the semantics of -y):

$ ffmpeg -f lavfi -i color out.png
$ ffmpeg -i out.png -s 640x640 -y out.png

comment:3 by Cigaes, 9 years ago

Someone who says -y without triple-checking the command line is asking for trouble. -y does exactly as it is meant to, and adding a special case for situations where the input and output file are the same would be fragile (with some networked protocols, in=out can make sense; with devices too) and solve only a very specific situation.
I suggest to close this as WONTFIX.

comment:4 by Carl Eugen Hoyos, 9 years ago

Resolution: wontfix
Status: newclosed

comment:5 by artofit, 9 years ago

Just mean it, because it happens by (too) quick copy pasting cli and only changing the source name...

It's simple to add some simple line instruction:

if strcmp(input_file_name, output_file_name) ==0 return IN_AND_OUT_FILE_ARE_THE_SAME


comment:6 by artofit, 9 years ago

Or
if (strlen(input_file_name) == strlen(output_file_name)) {

if (strcmp(input_file_name, output_file_name) ==0) return IN_AND_OUT_FILE_ARE_THE_SAME

}

comment:7 by Gyan, 6 years ago

Resolution: wontfixfixed
Note: See TracTickets for help on using tickets.