FFMPEG slideshow from images – only one frame shown

ffmpegslideshow

I am a beginner with ffmpeg.

I want to convert several images to a slideshow and came up with this command:

ffmpeg -y -r 1/5 -i *.jpg -r 25 output.mp4

Pretty straight forward. However, the video seems like only one frame long (it is too fast to recognize for me)

Here is the Ouput of the above command:

    ffmpeg version 0.8.9-4:0.8.9-0ubuntu0.12.04.1, Copyright (c) 2000-2013 the Libav developers
  built on Nov  9 2013 19:12:07 with gcc 4.6.3
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
Input #0, image2, from 'swirl3777.jpg':
  Duration: 00:00:05.00, start: 0.000000, bitrate: N/A
    Stream #0.0: Video: mjpeg, yuvj444p, 1600x1200 [PAR 72:72 DAR 4:3], 0.20 tbr, 0.20 tbn, 0.20 tbc
Incompatible pixel format 'yuvj444p' for codec 'mjpeg', auto-selecting format 'yuvj420p'
[buffer @ 0x86e2040] w:1600 h:1200 pixfmt:yuvj444p
[avsink @ 0x86e8920] auto-inserting filter 'auto-inserted scaler 0' between the filter 'src' and the filter 'out'
[scale @ 0x86e8d80] w:1600 h:1200 fmt:yuvj444p -> w:1600 h:1200 fmt:yuvj420p flags:0x4
Incompatible pixel format 'yuvj444p' for codec 'mjpeg', auto-selecting format 'yuvj420p'
[buffer @ 0x86e8c00] w:1600 h:1200 pixfmt:yuvj444p
[avsink @ 0x87159a0] auto-inserting filter 'auto-inserted scaler 0' between the filter 'src' and the filter 'out'
[scale @ 0x86f1860] w:1600 h:1200 fmt:yuvj444p -> w:1600 h:1200 fmt:yuvj420p flags:0x4
Incompatible pixel format 'yuvj444p' for codec 'mpeg4', auto-selecting format 'yuv420p'
[buffer @ 0x86f17c0] w:1600 h:1200 pixfmt:yuvj444p
[avsink @ 0x870f4a0] auto-inserting filter 'auto-inserted scaler 0' between the filter 'src' and the filter 'out'
[scale @ 0x8737e60] w:1600 h:1200 fmt:yuvj444p -> w:1600 h:1200 fmt:yuv420p flags:0x4
Output #0, image2, to 'swirl3786.jpg':
  Metadata:
    encoder         : Lavf53.21.1
    Stream #0.0: Video: mjpeg, yuvj420p, 1600x1200 [PAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 90k tbn, 0.20 tbc
Output #1, image2, to 'swirl3787.jpg':
  Metadata:
    encoder         : Lavf53.21.1
    Stream #1.0: Video: mjpeg, yuvj420p, 1600x1200 [PAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 90k tbn, 0.20 tbc
Output #2, mp4, to 'output.mp4':
  Metadata:
    encoder         : Lavf53.21.1
    Stream #2.0: Video: mpeg4, yuv420p, 1600x1200 [PAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 25 tbn, 25 tbc
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #0.0 -> #1.0
  Stream #0.0 -> #2.0
Press ctrl-c to stop encoding
frame=    1 fps=  0 q=10.2 Lq=10.2 q=9.5 size=      -0kB time=0.04 bitrate=  -4.4kbits/s    
video:584kB audio:0kB global headers:0kB muxing overhead -100.003680%

I also tried avconv but it's the same output, even the same file size.
If I change the -r values to something ridiculous like 3434321 it still get the same file size. If I add -b 512k oder -b 1024 it still get the same file size again…
It seems like, the options get ignored in some way.

The three pictures in the folder are detected correctly.

Is there any issues with the incompatible pixel format?

I am here on Ubuntu 12.04 ffmpeg version 0.8.9-4:0.8.9-0ubuntu0.12.04.1

Any guess, what I could have done wrong here? TIA

Best Answer

  • Glob

    ffmpeg from FFmpeg supports glob patterns, so your input files can be named almost anything as long as they are in the order you want:

    ffmpeg -framerate 1/5 -pattern_type glob -i "*.jpg" -vf "fps=25,format=yuv420p" out.mp4
    

    Ubuntu uses avconv and the buggy, fake "ffmpeg" from Libav, a fork of FFmpeg, and these do not support glob patterns. See Who can tell me the difference and relation between ffmpeg, libav, and avconv?

    Get ffmpeg

    To get ffmpeg, you can simply download a Linux build of ffmpeg or follow a step-by-step guide to compile ffmpeg.


    Potential Issues

    First image is skipped

    There are some unresolved issues or inconsistencies involving -r and the fps video filter. Sometimes the first input image appears to be skipped or displayed for only a frame. You can use the fps filter to avoid the skipping issue as shown in my example above. See tickets #1578 and #3164 for more info.

    Last image is skipped

    It may appear that the last image is skipped or displayed for one frame. I did not find an elegant solution to this behavior, but you can simply make a copy of the last image file to compensate.

    Even more skipping

    If your input images are not all the same pixel format and/or frame size then ffmpeg may skip an indeterminate number of frames. Make sure all input images are similar to avoid this. You can see the console output which will mention any input file differences.

    The output MP4 video does not play

    Use a less crappy player, or use the format filter as shown in my example, or use the -pix_fmt yuv420p output option. Otherwise ffmpeg will attempt to avoid or minimize chroma subsampling (depending on your input, the encoder you're using, your ffmpeg version, and the encoding options you use), and although this may be good in a technical sense, it can create an output that is not playable by non-FFmpeg based players.

  • Related Question