3

I've just downloaded ffmpeg since it seems to perfectly match my needs (make a video from a set of pictures). I'm currently playing around with some examples just to get started and there's something weird happening that I can't explain. I'm trying this command (provided in the official documentation):

ffmpeg -f image2 -pattern_type glob -i 'foo-*.jpeg' -r 12 -s WxH foo.avi

on a data set of 10 jpg pictures (of course I changed the pattern with '*.jpg'). The video seems to be encoded correctly but it's simply too fast to be sure about that (anyway it stops on the last frame that corresponds to the last picture). In order to get a longer video i thought to low the frame rate from 12 to 1 (one sec each picture) or 0.5 (2 sec each one) and so on.. no way! with low rate values even if the video is played the pictures are simply not displayed. The player (VLC in my case) just shows a blank/empty video for a few seconds.

Am I making something wrong or have I misunderstood the -r parameter? Is it something related to codecs involved? Finally.. How can i get each picture displayed for 1 or 2 seconds?

Here's the output:

MacBook-Pro$ ffmpeg -f image2 -pattern_type glob -i '*.jpg' -r 1 -s 200x300 foo.avi
ffmpeg version N-52517-g1e4f75d Copyright (c) 2000-2013 the FFmpeg developers
  built on Apr 27 2013 19:41:11 with llvm-gcc 4.2.1 (LLVM build 2336.11.00)
  configuration: --disable-yasm
  libavutil      52. 27.101 / 52. 27.101
  libavcodec     55.  6.100 / 55.  6.100
  libavformat    55.  3.100 / 55.  3.100
  libavdevice    55.  0.100 / 55.  0.100
  libavfilter     3. 61.100 /  3. 61.100
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
Input #0, image2, from '*.jpg':
  Duration: 00:00:00.40, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: mjpeg, yuvj422p, 2560x1920 [SAR 1:1 DAR 4:3], 25 fps, 25 tbr, 25 tbn, 25 tbc
File 'foo.avi' already exists. Overwrite ? [y/N] y
Output #0, avi, to 'foo.avi':
  Metadata:
    ISFT            : Lavf55.3.100
    Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 200x300 [SAR 2:1 DAR 4:3], q=2-31, 200 kb/s, 1 tbn, 1 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (mjpeg -> mpeg4)
Press [q] to stop, [?] for help
frame=    2 fps=0.0 q=2.0 Lsize=      43kB time=00:00:02.00 bitrate= 177.1kbits/s dup=0 drop=8    
video:38kB audio:0kB subtitle:0 global headers:0kB muxing overhead 15.099197%
MacBook-Pro$ 
5
  • What happens when you explicitly add -pix_fmt yuv420p to the options (before the output filename)? Although ffmpeg actually changes the pixel format just fine… hm. Can you also try a different video codec, e.g. -c:v libx264 -pix_fmt yuv420p output.mp4
    – slhck
    Apr 27, 2013 at 20:53
  • thanks for answering @slhck. The -pix_fmt yuv420p option didn't work (same result: VLC plays "something" for a few seconds but nothing is displayed). Switching to a different codec causes this error to me: ** Unknown encoder 'libx264' ** I'll try to get the libx264 installed and let you know
    – Marco Gagliardi
    Apr 27, 2013 at 21:29
  • Note that default -r value for input is 25. Setting -r only for output will convert from 25 to whatever your output is and will either drop or duplicate frames to reach your desired output frame rate. So instead try moving -r as an input option (anywhere before -i), and the output will use this same value. If the player still doesn't grok it you can add one for output, as in -r 25. Also, 200x300 will probably vertically stretch your output.
    – llogan
    Apr 28, 2013 at 15:46
  • Also, there are static builds of ffmpeg for OSX that include libx264.
    – llogan
    Apr 28, 2013 at 15:51
  • @LordNeckbeard I followed your suggestion and specifying the -r parameter before the -i one actually has effect on the result, but still does not solve completely the issue. The news is that the video still starts as if there were no images (the player's cursor advances on the progress bar but without any image displayed) but after a few seconds one of the pictures (the first one) now appears on the video! unfortunately this happens after a few seconds the video has started and only one picture of the set is displayed! Apr 29, 2013 at 9:25

0

You must log in to answer this question.

Browse other questions tagged .