1

I am trying to create an MP4 video from static images, *.png and *.jpg. The last image is being dropped from the mp4. Does anyone have any clues for me ? The images in the directory are :

@bambam:/tmp/create_reel/images/holding-00005> identify img0000*.png
img00001.png PNG 1280x779 1280x779+0+0 8-bit sRGB 1.311MB 0.000u 0:00.000
img00002.png PNG 1280x779 1280x779+0+0 8-bit sRGB 728KB 0.000u 0:00.000
img00003.png PNG 1280x779 1280x779+0+0 8-bit sRGB 1.311MB 0.000u 0:00.000
img00004.png PNG 1280x779 1280x779+0+0 8-bit sRGB 728KB 0.000u 0:00.000

ffmpeg is run :

ffmpeg -r 0.15 -i img%05d.png -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -c:v libx264 -pix_fmt yuv420p output.mp4
ffmpeg version N-77739-g7ab37ca Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5 (SUSE Linux)
  configuration: --prefix=/home/develop/ffmpeg_build --extra-cflags=-I/home/develop/ffmpeg_build/include --extra-ldflags=-L/home/develop/ffmpeg_build/lib --bindir=/home/develop/bin --pkg-config-flags=--static --enable-gpl --enable-nonfree --enable-libfreetype --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265
  libavutil      55. 13.100 / 55. 13.100
  libavcodec     57. 22.100 / 57. 22.100
  libavformat    57. 21.101 / 57. 21.101
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 23.100 /  6. 23.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Input #0, image2, from 'img%05d.png':
  Duration: 00:00:00.16, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: png, rgb24(pc), 1280x779, 25 fps, 25 tbr, 25 tbn, 25 tbc
[libx264 @ 0x386a200] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 LZCNT
[libx264 @ 0x386a200] profile High, level 3.2
[libx264 @ 0x386a200] 264 - core 148 r2 7599210 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=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 chroma_qp_offset=-2 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=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 scenecut=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 'output.mp4':
  Metadata:
    encoder         : Lavf57.21.101
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1280x778, q=-1--1, 0.15 fps, 12288 tbn, 0.15 tbc
Metadata:
  encoder         : Lavc57.22.100 libx264
Side data:
  unknown side data type 10 (24 bytes)
Stream mapping:
  Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
Press [q] to stop, [?] for help
frame=    4 fps=0.0 q=-1.0 Lsize=     525kB time=00:00:13.33 bitrate=     322.7kbits/s speed=29.4x    
video:524kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.164819%
[libx264 @ 0x386a200] frame I:1     Avg QP:16.23  size:246200
[libx264 @ 0x386a200] frame P:2     Avg QP:16.29  size: 72244
[libx264 @ 0x386a200] frame B:1     Avg QP:15.11  size:145580
[libx264 @ 0x386a200] consecutive B-frames: 50.0% 50.0%  0.0%  0.0%
[libx264 @ 0x386a200] mb I  I16..4:  4.2% 43.3% 52.5%
[libx264 @ 0x386a200] mb P  I16..4: 21.6%  8.5% 19.7%  P16..4:  1.8%  0.1%  0.2%  0.0%  0.0%    skip:48.0%
[libx264 @ 0x386a200] mb B  I16..4: 43.4% 16.4% 39.8%  B16..8:  0.0%  0.1%  0.2%  direct: 0.0%  skip: 0.0%  L0:89.8% L1:10.2% BI: 0.0%
[libx264 @ 0x386a200] 8x8 transform intra:25.6% inter:2.6%
[libx264 @ 0x386a200] coded y,uvDC,uvAC intra: 62.8% 57.0% 49.5% inter: 1.1% 3.0% 0.2%
[libx264 @ 0x386a200] i16 v,h,dc,p: 76% 17%  4%  4%
[libx264 @ 0x386a200] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 11% 22% 16%  6%  8%  6% 11%  7% 11%
[libx264 @ 0x386a200] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 21% 12%  6%  8%  7%  8%  6%  7%
[libx264 @ 0x386a200] i8c dc,h,v,p: 39% 43% 12%  6%
[libx264 @ 0x386a200] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x386a200] ref P L0: 91.7%  5.8%  2.5%
[libx264 @ 0x386a200] kb/s:160.88

-rw-r--r-- 1 develop users 537839 Jan  9 10:27 output.mp4

An obvious workaround is to duplicate the last image, it's a bit of a hack though and I'd rather create the movie "properly"

  • Turns out that the last image is being dropped by mplayer. If I use smplayer then all images are displayed and Quicktime (Windows) also shows all images. Apparently though Windows Media only displays the first frame. – burtzerk Jan 8 '16 at 22:08
0

The last image isn't being dropped as such. Each frame is drawn as per its presentation timestamp. The 'persistence' of each frame occurs between the drawing of two frames. After the last drawing operation the playback stops.

Besides the hack of duplicating the last image, another hack is to generate a dummy audio of length no. of frames x duration of each frame display - the second term is a reciprocal of the framerate. So, try this:

ffmpeg -r 0.15 -i img%05d.png -f lavfi -i "aevalsrc=0:d=26.667" -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -c:v libx264 -pix_fmt yuv420p output.mp4
  • Thanks, I tried that. It didn't have the desired effect in mplayer. The image times were : Img 1: 12s Img 2 : 5s Img 3 : 6s Im4 4 : 1s – burtzerk Jan 9 '16 at 19:21
0

I think the problem is actually in mplayer. The command mplayer -fs -nosound mf://*.png -mf fps=1/5" plays the last image for about 1 second, all the others are played for 5 seconds. My solution will be to use another player for images.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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