Opened 12 years ago

Closed 11 years ago

#1637 closed defect (fixed)

ffmpeg: no confirmation when overwriting still images

Reported by: Clément Bœsch Owned by:
Priority: minor Component: ffmpeg
Version: git-master Keywords: overwriting image2
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

ffmpeg does the overwriting confirmation, except in the case of image2 muxer:

% touch out.mpg
% ./ffmpeg -f lavfi -i testsrc=d=5 -frames:v 1 out.mpg
ffmpeg version N-43492-g7106000 Copyright (c) 2000-2012 the FFmpeg developers
  built on Aug 13 2012 09:00:22 with gcc 4.7 (Debian 4.7.1-6)
  configuration: --enable-gpl --enable-fontconfig --enable-libfreetype --enable-libmp3lame --cc='ccache cc' --extra-cflags=-fstack-protector-all --enable-libx264 --enable-libvorbis --enable-libmodplug --enable-libass --samples=/home/cboesch/fate-samples --prefix=/home/cboesch/src/ff/ffmpeg/ffmpeg_build --enable-x11grab
  libavutil      51. 69.100 / 51. 69.100
  libavcodec     54. 52.100 / 54. 52.100
  libavformat    54. 23.100 / 54. 23.100
  libavdevice    54.  2.100 / 54.  2.100
  libavfilter     3.  8.100 /  3.  8.100
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
[lavfi @ 0x1d23260] Estimating duration from bitrate, this may be inaccurate
Input #0, lavfi, from 'testsrc=d=5':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 320x240 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc
File 'out.mpg' already exists. Overwrite ? [y/N] n
Not overwriting - exiting
% touch out.png
% ./ffmpeg -f lavfi -i testsrc=d=5 -frames:v 1 out.png
ffmpeg version N-43492-g7106000 Copyright (c) 2000-2012 the FFmpeg developers
  built on Aug 13 2012 09:00:22 with gcc 4.7 (Debian 4.7.1-6)
  configuration: --enable-gpl --enable-fontconfig --enable-libfreetype --enable-libmp3lame --cc='ccache cc' --extra-cflags=-fstack-protector-all --enable-libx264 --enable-libvorbis --enable-libmodplug --enable-libass --samples=/home/cboesch/fate-samples --prefix=/home/cboesch/src/ff/ffmpeg/ffmpeg_build --enable-x11grab
  libavutil      51. 69.100 / 51. 69.100
  libavcodec     54. 52.100 / 54. 52.100
  libavformat    54. 23.100 / 54. 23.100
  libavdevice    54.  2.100 / 54.  2.100
  libavfilter     3.  8.100 /  3.  8.100
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
[lavfi @ 0x2cc2260] Estimating duration from bitrate, this may be inaccurate
Input #0, lavfi, from 'testsrc=d=5':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 320x240 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc
Output #0, image2, to 'out.png':
  Metadata:
    encoder         : Lavf54.23.100
    Stream #0:0: Video: png, rgb24, 320x240 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 90k tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> png)
Press [q] to stop, [?] for help
frame=    1 fps=0.0 q=0.0 Lsize=       0kB time=00:00:00.04 bitrate=   0.0kbits/s    
video:3kB audio:0kB subtitle:0 global headers:0kB muxing overhead -100.000000%

It seems to be due to the AVFMT_NOFILE flag, since this fixes the issue:

diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
index d162cef..bd8738d 100644
--- a/libavformat/img2enc.c
+++ b/libavformat/img2enc.c
@@ -159,7 +159,7 @@ AVOutputFormat ff_image2_muxer = {
     .video_codec    = AV_CODEC_ID_MJPEG,
     .write_header   = write_header,
     .write_packet   = write_packet,
-    .flags          = AVFMT_NOTIMESTAMPS | AVFMT_NODIMENSIONS | AVFMT_NOFILE,
+    .flags          = AVFMT_NOTIMESTAMPS | AVFMT_NODIMENSIONS,
     .priv_class     = &img2mux_class,
 };

I'm not sure why that flag was here in the first place so...

Change History (1)

comment:1 by Michael Niedermayer, 11 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.