[FFmpeg-user] overlaying animated PNG, doesn't loop

Dave Thorn davet at fysh.org
Fri Jan 8 16:47:27 EET 2021


Coming back to ffmpeg after a while away, so my version is probably a
bit out of date by now[1]

I have an animated PNG that loops forever (it does in firefox and
chrome, and looking inside with a hex editor I think it specifies
infinite looping).

ffmpeg -i input.mp4 -i elephant.apng -filter_complex "[0:v][1:v] overlay=25:25:enable='between(t,0,4)'" -pix_fmt yuv420p -c:a copy output.mp4

Produces a video where the apng loops once, then stops.


[1]


$ ffmpeg -i input.mp4 -i elephant.apng -filter_complex "[0:v][1:v] overlay=25:25:enable='between(t,0,4)'" -pix_fmt yuv420p -c:a copy output.mp4
ffmpeg version N-92054-ga7429d853d Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 8.2.1 (GCC) 20180813
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid--enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
  libavutil      56. 19.101 / 56. 19.101
  libavcodec     58. 31.100 / 58. 31.100
  libavformat    58. 18.102 / 58. 18.102
  libavdevice    58.  4.104 / 58.  4.104
  libavfilter     7. 32.100 /  7. 32.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
  libpostproc    55.  2.100 / 55.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.18.102
  Duration: 00:00:04.04, start: 0.000000, bitrate: 28 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 24 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)
    Metadata:
      handler_name    : VideoHandler
Input #1, apng, from 'elephant.apng':
  Duration: N/A, bitrate: N/A
    Stream #1:0: Video: apng, rgba(pc), 480x400, 24 fps, 24 tbr, 100k tbn, 100k tbc
Stream mapping:
  Stream #0:0 (h264) -> overlay:main
  Stream #1:0 (apng) -> overlay:overlay
  overlay -> Stream #0:0 (libx264)
Press [q] to stop, [?] for help
[libx264 @ 000001fd35c99d80] using SAR=1/1
[libx264 @ 000001fd35c99d80] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 000001fd35c99d80] profile High, level 4.0, 4:2:0, 8-bit
[libx264 @ 000001fd35c99d80] 264 - core 157 r2932 303c484 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - 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=12 lookahead_threads=2 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=24 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:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.18.102
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 24 fps, 12288tbn, 24 tbc (default)
    Metadata:
      encoder         : Lavc58.31.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame=   97 fps=0.0 q=-1.0 Lsize=      59kB time=00:00:03.91 bitrate= 123.9kbits/s speed=4.84x
video:57kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 3.439929%
[libx264 @ 000001fd35c99d80] frame I:1     Avg QP:17.15  size:  8109
[libx264 @ 000001fd35c99d80] frame P:24    Avg QP:16.50  size:   952
[libx264 @ 000001fd35c99d80] frame B:72    Avg QP:17.75  size:   375
[libx264 @ 000001fd35c99d80] consecutive B-frames:  1.0%  0.0%  0.0% 99.0%
[libx264 @ 000001fd35c99d80] mb I  I16..4: 23.6% 74.4%  2.1%
[libx264 @ 000001fd35c99d80] mb P  I16..4:  0.2%  0.1%  0.1%  P16..4:  1.0%  0.3%  0.1%  0.0%  0.0%    skip:98.2%
[libx264 @ 000001fd35c99d80] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  1.0%  0.2%  0.0%  direct: 0.0%  skip:98.8%  L0:47.2% L1:50.7% BI: 2.1%
[libx264 @ 000001fd35c99d80] 8x8 transform intra:70.6% inter:18.3%
[libx264 @ 000001fd35c99d80] coded y,uvDC,uvAC intra: 2.8% 7.3% 4.8% inter: 0.1% 0.1% 0.1%
[libx264 @ 000001fd35c99d80] i16 v,h,dc,p: 86%  8%  5%  1%
[libx264 @ 000001fd35c99d80] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 71% 12% 16%  0%  0%  0%  0%  0%  0%
[libx264 @ 000001fd35c99d80] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 25% 28%  4%  3%  4%  4%  3%  4%
[libx264 @ 000001fd35c99d80] i8c dc,h,v,p: 84%  5% 11%  0%
[libx264 @ 000001fd35c99d80] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 000001fd35c99d80] ref P L0: 68.6%  0.9% 16.8% 13.7%
[libx264 @ 000001fd35c99d80] ref B L0: 70.8% 26.2%  2.9%
[libx264 @ 000001fd35c99d80] ref B L1: 96.1%  3.9%
[libx264 @ 000001fd35c99d80] kb/s:114.75



-- 
dave thorn

With great power comes great responsibility.


More information about the ffmpeg-user mailing list