[FFmpeg-user] concatenate png files for different durations?
Spencer Graves
spencer.graves at prodsyse.com
Fri Mar 14 17:20:41 CET 2014
On 3/14/2014 2:49 AM, Tom Evans wrote:
> On Fri, Mar 14, 2014 at 1:58 AM, Spencer Graves
> <spencer.graves at prodsyse.com> wrote:
>> How can I display a sequence of png files for different time durations
>> and mate them with a single audio?
>>
>>
>> Attached is a toy example: I want to display tst1.png for 0.5 seconds
>> followed by tst2.png for 1.5 seconds and merge that video with the audio in
>> tst2.mp2.
>>
>>
>> If I don't care about the display time for each image, I can merge
>> these 2 png and 1 mp2 files with "ffmpeg -y -r 1 -i tst.mp2 -r 2 -i
>> tst%d.png -b 300k tst.mp4".
>>
>>
>> The documentation describes "concat" for filter, demuxer, protocol,
>> and raw. I was unable to see how any of these would solve this problem.
>>
>>
>> Thanks,
>> Spencer
>>
>>
>> p.s. I'm using ffmpeg version N-61163-gd1122b7 Copyright (c) 2000-2014 the
>> FFmpeg developers built on Mar 7 2014 22:01:29 with gcc 4.8.2 (GCC) under
>> Windows 7 Home Edition with a dual core Intel processor, 8 GB RAM, and lots
>> of free hard drive.
>>
> Create a directory and place one png file per the smallest duration
> that you want for a single image. Use this duration as your input
> frame-rate.
>
> If you want a particular image to repeat for multiple input frames,
> put the image in the directory twice. On a more feature-full OS, you
> could do this without copying by symlinking the file in place.
>
> Eg, for your example:
>
> mkdir sources
> cp tst1.png sources/00001.png
> cp tst2.png sources/00002.png
> cp tst2.png sources/00003.png
> cp tst2.png sources/00004.png
>
> ffmpeg -r 2 -i sources/%05d.png -r 30 -pix_fmt yuv420p out.mp4
Unfortunately, when I tried this, 00001.png seemed to display for
0.1 second or less; it was certainly much less than the 0.5 seconds
implied by "-r 2".
The problem is much worse in a larger example: I have a
60-second audio recording that I want to sync with 15 png images. In
that case, I don't see the first image at all. The second displays for
15 seconds before it starts showing the other 13 images at 4 seconds per
image. Below please find what I got from running this toy example with
and without the audio file. This relates to my other post on "ffmpeg
synchronization", stamped 13 Mar 2014 21:35:10 -0700.
##### WITH THE AUDIO (FOLLOWED BY WITHOUT
>ffmpeg -y -r 1 -i tst2.mp2 -r 2 -i sources/%05d.png -r
30 -pix_fmt yuv420p tst2.mp4
ffmpeg version N-61163-gd1122b7 Copyright (c) 2000-2014 the FFmpeg
developers
built on Mar 7 2014 22:01:29 with gcc 4.8.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads
--enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r
--enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libcaca
--enable-libfreetyp
e --enable-libgsm --enable-libilbc --enable-libmodplug
--enable-libmp3lame --ena
ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg
--enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr
--enable-libsp
eex --enable-libtheora --enable-libtwolame --enable-libvidstab
--enable-libvo-aa
cenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx
--enable-libwavp
ack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid
--enable
-zlib
libavutil 52. 66.101 / 52. 66.101
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.101 / 55. 33.101
libavdevice 55. 11.100 / 55. 11.100
libavfilter 4. 3.100 / 4. 3.100
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 18.100 / 0. 18.100
libpostproc 52. 3.100 / 52. 3.100
[mp3 @ 02865400] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from 'tst2.mp2':
Metadata:
album : test2
title : audio
track : 1
artist : Spencer Graves
genre : test
date : 2014
Duration: 00:00:02.04, start: 0.000000, bitrate: 157 kb/s
Stream #0:0: Audio: mp2, 44100 Hz, stereo, s16p, 157 kb/s
Input #1, image2, from 'sources/%05d.png':
Duration: 00:00:00.16, start: 0.000000, bitrate: N/A
Stream #1:0: Video: png, pal8, 480x480, 25 fps, 25 tbr, 25 tbn, 25 tbc
[libx264 @ 02880a80] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
[libx264 @ 02880a80] profile High, level 3.0
[libx264 @ 02880a80] 264 - core 142 r2389 956c8d8 - H.264/MPEG-4 AVC
codec - Cop
yleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1
ref=3 deb
lock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00
mixed_ref=1 m
e_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11
fast_pskip=1 chro
ma_qp_offset=-2 threads=6 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=25 scenec
ut=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 'tst2.mp4':
Metadata:
album : test2
title : audio
track : 1
artist : Spencer Graves
genre : test
date : 2014
encoder : Lavf55.33.101
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021),
yuv420p, 480x48
0, q=-1--1, 15360 tbn, 30 tbc
Stream #0:1: Audio: aac (libvo_aacenc) ([64][0][0][0] / 0x0040),
44100 Hz, s
tereo, s16, 128 kb/s
Stream mapping:
Stream #1:0 -> #0:0 (png -> libx264)
Stream #0:0 -> #0:1 (mp2 -> libvo_aacenc)
Press [q] to stop, [?] for help
frame= 46 fps=0.0 q=-1.0 Lsize= 40kB time=00:00:02.03 bitrate=
159.7kbits
/s dup=42 drop=0
video:4kB audio:32kB subtitle:0 data:0 global headers:0kB muxing
overhead 8.5601
76%
[libx264 @ 02880a80] frame I:1 Avg QP:20.96 size: 1966
[libx264 @ 02880a80] frame P:12 Avg QP:12.28 size: 53
[libx264 @ 02880a80] frame B:33 Avg QP:13.96 size: 27
[libx264 @ 02880a80] consecutive B-frames: 4.3% 0.0% 0.0% 95.7%
[libx264 @ 02880a80] mb I I16..4: 21.9% 73.2% 4.9%
[libx264 @ 02880a80] mb P I16..4: 0.0% 0.0% 0.0% P16..4: 0.0%
0.0% 0.0%
0.0% 0.0% skip:99.9%
[libx264 @ 02880a80] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.5%
0.0% 0.0%
direct: 0.0% skip:99.5% L0:65.6% L1:34.4% BI: 0.0%
[libx264 @ 02880a80] 8x8 transform intra:72.8% inter:0.0%
[libx264 @ 02880a80] coded y,uvDC,uvAC intra: 2.6% 2.4% 2.3% inter: 0.0%
0.0% 0.
0%
[libx264 @ 02880a80] i16 v,h,dc,p: 52% 33% 15% 0%
[libx264 @ 02880a80] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 69% 8% 24% 0% 0%
0% 0%
0% 0%
[libx264 @ 02880a80] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 46% 28% 16% 1% 1%
2% 2%
1% 2%
[libx264 @ 02880a80] i8c dc,h,v,p: 98% 1% 1% 0%
[libx264 @ 02880a80] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 02880a80] ref P L0: 66.7% 0.0% 33.3%
[libx264 @ 02880a80] ref B L0: 36.2% 62.9% 1.0%
[libx264 @ 02880a80] ref B L1: 98.2% 1.8%
[libx264 @ 02880a80] kb/s:18.16
### WITHOUT THE AUDIO
>ffmpeg -y -r 2 -i s2/%05d.png -r 30 -pix_fmt yuv420p tst2d.mp4
ffmpeg version N-61163-gd1122b7 Copyright (c) 2000-2014 the FFmpeg
developers
built on Mar 7 2014 22:01:29 with gcc 4.8.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads
--enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r
--enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libcaca
--enable-libfreetyp
e --enable-libgsm --enable-libilbc --enable-libmodplug
--enable-libmp3lame --ena
ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg
--enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr
--enable-libsp
eex --enable-libtheora --enable-libtwolame --enable-libvidstab
--enable-libvo-aa
cenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx
--enable-libwavp
ack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid
--enable
-zlib
libavutil 52. 66.101 / 52. 66.101
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.101 / 55. 33.101
libavdevice 55. 11.100 / 55. 11.100
libavfilter 4. 3.100 / 4. 3.100
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 18.100 / 0. 18.100
libpostproc 52. 3.100 / 52. 3.100
Input #0, image2, from 's2/%05d.png':
Duration: 00:00:00.16, start: 0.000000, bitrate: N/A
Stream #0:0: Video: png, pal8, 480x480, 25 fps, 25 tbr, 25 tbn, 25 tbc
[libx264 @ 042dfc20] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
[libx264 @ 042dfc20] profile High, level 3.0
[libx264 @ 042dfc20] 264 - core 142 r2389 956c8d8 - H.264/MPEG-4 AVC
codec - Cop
yleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1
ref=3 deb
lock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00
mixed_ref=1 m
e_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11
fast_pskip=1 chro
ma_qp_offset=-2 threads=6 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=25 scenec
ut=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 'tst2d.mp4':
Metadata:
encoder : Lavf55.33.101
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021),
yuv420p, 480x48
0, q=-1--1, 15360 tbn, 30 tbc
Stream mapping:
Stream #0:0 -> #0:0 (png -> libx264)
Press [q] to stop, [?] for help
frame= 46 fps=0.0 q=-1.0 Lsize= 5kB time=00:00:01.46 bitrate=
30.3kbits
/s dup=42 drop=0
video:4kB audio:0kB subtitle:0 data:0 global headers:0kB muxing overhead
32.0579
83%
[libx264 @ 042dfc20] frame I:1 Avg QP:20.96 size: 1966
[libx264 @ 042dfc20] frame P:12 Avg QP:12.28 size: 53
[libx264 @ 042dfc20] frame B:33 Avg QP:13.96 size: 27
[libx264 @ 042dfc20] consecutive B-frames: 4.3% 0.0% 0.0% 95.7%
[libx264 @ 042dfc20] mb I I16..4: 21.9% 73.2% 4.9%
[libx264 @ 042dfc20] mb P I16..4: 0.0% 0.0% 0.0% P16..4: 0.0%
0.0% 0.0%
0.0% 0.0% skip:99.9%
[libx264 @ 042dfc20] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.5%
0.0% 0.0%
direct: 0.0% skip:99.5% L0:65.6% L1:34.4% BI: 0.0%
[libx264 @ 042dfc20] 8x8 transform intra:72.8% inter:0.0%
[libx264 @ 042dfc20] coded y,uvDC,uvAC intra: 2.6% 2.4% 2.3% inter: 0.0%
0.0% 0.
0%
[libx264 @ 042dfc20] i16 v,h,dc,p: 52% 33% 15% 0%
[libx264 @ 042dfc20] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 69% 8% 24% 0% 0%
0% 0%
0% 0%
[libx264 @ 042dfc20] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 46% 28% 16% 1% 1%
2% 2%
1% 2%
[libx264 @ 042dfc20] i8c dc,h,v,p: 98% 1% 1% 0%
[libx264 @ 042dfc20] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 042dfc20] ref P L0: 66.7% 0.0% 33.3%
[libx264 @ 042dfc20] ref B L0: 36.2% 62.9% 1.0%
[libx264 @ 042dfc20] ref B L1: 98.2% 1.8%
[libx264 @ 042dfc20] kb/s:18.16
> Cheers
>
> Tom
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
More information about the ffmpeg-user
mailing list