Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I created an AVI file from 30 PNG images, 15 frames/second:

ffmpeg -i %02d.png -r 15 video.avi

But when I tried to get the images back from the AVI:

ffmpeg -i src.avi %02d.png

I only got 19 images, instead 30! I also tried these two:

ffmpeg -i src.avi -r 15 %02d.png
ffmpeg -r 15 -i src.avi %02d.png

both with same result. Needless to say that there are missing frames (jumps from 4th to 6th, for instance). How come and how do I solve it?

Output for first command (ffmpeg -i %02d.png -r 15 video.avi):

ffmpeg version N-50314-gf6fff8e Copyright (c) 2000-2013 the FFmpeg developers
  built on Feb 25 2013 21:57:41 with gcc 4.7.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
  libavutil      52. 17.103 / 52. 17.103
  libavcodec     54. 92.100 / 54. 92.100
  libavformat    54. 63.100 / 54. 63.100
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 41.100 /  3. 41.100
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, image2, from '%02d.png':
  Duration: 00:00:01.20, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: png, rgb24, 713x386 [SAR 3779:3779 DAR 713:386], 25 fps, 25 tbr, 25 tbn, 25 tbc
Output #0, avi, to 'video.avi':
  Metadata:
    ISFT            : Lavf54.63.100
    Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 713x386 [SAR 1:1 DAR 713:386], q=2-31, 200 kb/s, 15 tbn, 15 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (png -> mpeg4)
Press [q] to stop, [?] for help
frame=   19 fps=0.0 q=2.0 Lsize=      46kB time=00:00:01.26 bitrate= 297.1kbits/s dup=0 drop=11    

video:40kB audio:0kB subtitle:0 global headers:0kB muxing overhead 15.248175%

Output for second command (ffmpeg -i video.avi %02d.png):

ffmpeg version N-50314-gf6fff8e Copyright (c) 2000-2013 the FFmpeg developers
  built on Feb 25 2013 21:57:41 with gcc 4.7.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
  libavutil      52. 17.103 / 52. 17.103
  libavcodec     54. 92.100 / 54. 92.100
  libavformat    54. 63.100 / 54. 63.100
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 41.100 /  3. 41.100
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, avi, from 'video.avi':
  Metadata:
    encoder         : Lavf54.63.100
  Duration: 00:00:01.27, start: 0.000000, bitrate: 297 kb/s
    Stream #0:0: Video: mpeg4 (Simple Profile) (FMP4 / 0x34504D46), yuv420p, 713x386 [SAR 1:1 DAR 713:386], 15 tbr, 15 tbn, 15 tbc
Output #0, image2, to '%02d.png':
  Metadata:
    encoder         : Lavf54.63.100
    Stream #0:0: Video: png, rgb24, 713x386 [SAR 1:1 DAR 713:386], q=2-31, 200 kb/s, 90k tbn, 15 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg4 -> png)
Press [q] to stop, [?] for help
frame=   19 fps=0.0 q=0.0 Lsize=N/A time=00:00:01.26 bitrate=N/A    

video:129kB audio:0kB subtitle:0 global headers:0kB muxing overhead -100.016665%
share|improve this question
    
Please include the complete ffmpeg console output for your first two commands. I have an idea of what the issue is, but I don't like to guess without the complete ffmpeg console output: it contains useful information that will help determine the issue. Also, what player are you using? How can you tell there are missing frames? –  LordNeckbeard Feb 26 '13 at 18:50
    
@LordNeckbeard - I edited my question with the outputs –  Tal Feb 27 '13 at 11:29

1 Answer 1

up vote 5 down vote accepted

You need to move -r 15 as an input option for your first command:

ffmpeg -r 15 -i %02d.png -qscale:v 2 video.avi

Otherwise ffmpeg will use the default -r 25 for your input, and if a different value is used for the output then frames will be dropped or duplicated to achieve your desired output frame rate.

If you only supply an input frame rate, then ffmpeg will inherit that same frame rate for the output without dropping or duplicating frames.

I added -qscale:v 2. This will provide a nice quality output, and increasing the value will decrease the output quality. 2-5 is a good range. Not declaring a -qscale:v or -b:v will use the default of -b:v 200k which will likely provide a bad looking output (depending on your input of course).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.