0

I asked this on another forum but never had any luck. I found the following command online that is supposed to create a video from images(duration of 5 seconds each) using FFmpeg.

ffmpeg -f image2 -r 1/5 -i img%03d.png -vcodec libx264 out.mp4

I have ran that and I have two images named img001.png and img002.png, however when I play out.mp4, it's only a 5 second clip with img001.png being played. What's really strange as well, is in my Windows Media Player, it thinks it's 10 seconds long (2 images @ 10 seconds), but when the gauge gets half way through(5 seconds) the video, it ends.

Any suggestions of what could be going on?

I also tried a bunch of other commands I found online but never had any luck. They would end up showing both images, but the first one would just flash for a fraction of a second, or some other ones would do the same thing would happen to the second image at the end of the video.

I have it ImageMagick installed into XAMPP on my Windows Vista PC. I can provide my command line output from the command if needed.

Edit: Added command line output

C:\xampp\htdocs>ffmpeg -f image2 -r 1/5 -i img%03d.png -vcodec libx264 out.mp4
ffmpeg version N-50911-g9efcfbe Copyright (c) 2000-2013 the FFmpeg developers
  built on Mar 13 2013 21:26:48 with gcc 4.7.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libg
sm --enable-libilbc --enable-libmp3lame --enable-libopencore-amrnb --enable-libo
pencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-li
bschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-lib
twolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enabl
e-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
  libavutil      52. 19.100 / 52. 19.100
  libavcodec     55.  0.100 / 55.  0.100
  libavformat    55.  0.100 / 55.  0.100
  libavdevice    54.  4.100 / 54.  4.100
  libavfilter     3. 45.103 /  3. 45.103
  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 'img%03d.png':
  Duration: 00:00:10.00, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: png, rgb24, 800x600 [SAR 1:1 DAR 4:3], 0.20 tbr, 0.20 tb
n, 0.20 tbc
[libx264 @ 0032cae0] using SAR=1/1
[libx264 @ 0032cae0] using cpu capabilities: MMX2 SSE2Slow SlowCTZ
[libx264 @ 0032cae0] profile High 4:4:4 Predictive, level 3.1, 4:4:4 8-bit
[libx264 @ 0032cae0] 264 - core 130 r2274 c832fe9 - H.264/MPEG-4 AVC codec - Cop
yright 2003-2013 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 de
block=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 chr
oma_qp_offset=4 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 i
nterlaced=0 bluray_compat=0 constrained_intra=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=1 scenecu
t=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 'out.mp4':
  Metadata:
    encoder         : Lavf55.0.100
    Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv444p, 800x600 [SAR 1:1
 DAR 4:3], q=-1--1, 16384 tbn, 0.20 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (png -> libx264)
Press [q] to stop, [?] for help
frame=    2 fps=0.0 q=2621023.0 Lsize=      37kB time=00:00:10.00 bitrate=  30.0
kbits/s
video:36kB audio:0kB subtitle:0 global headers:0kB muxing overhead 2.142993%
[libx264 @ 0032cae0] frame I:1     Avg QP:11.18  size: 17627
[libx264 @ 0032cae0] frame P:1     Avg QP:11.45  size: 18415
[libx264 @ 0032cae0] mb I  I16..4: 18.3% 69.5% 12.3%
[libx264 @ 0032cae0] mb P  I16..4: 11.6% 60.1%  9.7%  P16..4:  8.9%  6.6%  2.2%
 0.0%  0.0%    skip: 0.8%
[libx264 @ 0032cae0] 8x8 transform intra:71.4% inter:67.1%
[libx264 @ 0032cae0] coded y,u,v intra: 57.0% 24.1% 22.3% inter: 42.6% 25.7% 16.
4%
[libx264 @ 0032cae0] i16 v,h,dc,p: 28% 50% 15%  8%
[libx264 @ 0032cae0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 39% 28%  2%  2%  2%  3%
 3%  4%
[libx264 @ 0032cae0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 14% 53% 23%  1%  2%  2%  3%
 0%  2%
[libx264 @ 0032cae0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0032cae0] kb/s:28.83

C:\xampp\htdocs>
user3276588
  • 73
  • 1
  • 2
  • 7
  • @LordNeckbeard I have added the command line output if that is what you are referring to by the ffmpeg console output. Also, I do plan on using this with PHP and exec(). But I never knew FFMpeg couldn't be used in this site? It looks like there are a lot of other people using it. – user3276588 Feb 05 '14 at 19:41
  • See, e.g. http://stackoverflow.com/questions/7468274/ffmpeg-images-to-video-script-anyone – Fredrik Pihl Feb 05 '14 at 19:45
  • @fredrilPhil I tried that but then it says "Invalid frame size: WxH". When I remove the size, it only creates a 0 second video that quickly shows two frames. Know how I could add length to each image? I added -r 1/5 to the start of that same syntax you linked to and it just played the first image at 5 seconds and flashed the second one at the very end. – user3276588 Feb 05 '14 at 20:10
  • Did you actually replaced "W" and "H" by some real values like "1920" and "1080" for full HD ? – AJ29 Feb 05 '14 at 21:08
  • `frame= 2` seems suspect do the files all line up right? – rogerdpack Feb 05 '14 at 21:14
  • @AJ29 Oops. I totally didn't realize WxH stood for width and height. I guess that explains why I was getting errors with it--I thought it was just some letters for a predefined size. However, I tried removing "-s WxH" earlier, and also now just adding in the dimensions and neither made a difference. Maybe does "-f image2" need anything done to it? I couldn't figure out what it was or meant. I'm trying the following now: ffmpeg -f image2 -i img%03d.png-r 12 -s 1920x1080 foo.avi -- Still not working unfortunately – user3276588 Feb 05 '14 at 21:36
  • @rogerdpack I think so. I have them in a folder named img000.png and img001.png. Previously I was trying img001.png img002.png. The folder has other files in it. I don't think that would cause any issues would it? It just has other PHP files and stuff, no other images. – user3276588 Feb 05 '14 at 21:40
  • odd, this works here (using your command line): https://gist.github.com/rdp/8847062 – rogerdpack Feb 06 '14 at 16:02
  • I tried that too, but not having any luck :( Someone else on here mentioned I might need to upgrade my version of ffmpeg, although I didn't even install it in the first place. I installed imagemagick which apparently comes with some version of ffmpeg. So I ended up uninstalling imagemagick and tried installing the latest Zeranoe FFmpeg Build Version "git-9c978f2", but am still having issues. Not sure what's going on or if I just need to switch over to a linux operating system or something. I'm using Xampp on Windows Vista. – user3276588 Feb 06 '14 at 16:55

1 Answers1

1

I think your only problem is that you're not telling ffmpeg what output format to use.

try ffmpeg -f image2 -r 1/5 -i img%03d.png -vcodec libx264 -pix_fmt yuv420p out.mp4

Also remember that the images have to be the same size. You'll need to preprocess them to the same size if they're not.

good luck

bobbdelsol
  • 996
  • 6
  • 21