Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm having a hard time mixing a background png with a transparent flv. I scale and crop an flv video with filter_complex, and then i want to overlay it on a background png.

When I put the png in the background by setting it as the first input in the overlay filter i'm getting errors, and the result is a video with only the png and audio from the video. This is my command + complete output:

iMacBert:test bert$ ffmpeg -i test.flv -i test.png -filter_complex '[0:v]scale=max(552\, 420*iw/ih):-1[OUT1]; [OUT1]crop=552:420[OUT2];[1:v][OUT2]overlay[out]' -map [out] -map 0:a -t 00:00:10 -s 552x420 out.mp4
ffmpeg version 1.1.2 Copyright (c) 2000-2013 the FFmpeg developers
  built on Mar  4 2013 11:19:29 with Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
  configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libtheora --enable-libschroedinger --enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libspeex --enable-libfreetype --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/clang --arch=x86_64 --enable-yasm --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid --enable-nonfree --enable-libfaac
  libavutil      52. 13.100 / 52. 13.100
  libavcodec     54. 86.100 / 54. 86.100
  libavformat    54. 59.106 / 54. 59.106
  libavdevice    54.  3.102 / 54.  3.102
  libavfilter     3. 32.100 /  3. 32.100
  libswscale      2.  1.103 /  2.  1.103
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, flv, from 'test.flv':
  Metadata:
    audiodelay      : 0
    canSeekToEnd    : true
  Duration: 00:00:41.48, start: 0.000000, bitrate: 6444 kb/s
    Stream #0:0: Video: vp6a, yuva420p, 1920x1080, 10240 kb/s, 25 tbr, 1k tbn, 1k tbc
    Stream #0:1: Audio: mp3, 44100 Hz, stereo, s16p, 128 kb/s
Input #1, image2, from 'test.png':
  Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
    Stream #1:0: Video: png, rgba, 552x420 [SAR 2835:2835 DAR 46:35], 25 tbr, 25 tbn, 25 tbc
File 'out.mp4' already exists. Overwrite ? [y/N] y
using SAR=1/1
[libx264 @ 0x7fe10b042a00] using cpu capabilities: none!
[libx264 @ 0x7fe10b042a00] profile High, level 3.0
[libx264 @ 0x7fe10b042a00] 264 - core 128 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - 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=25 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 'out.mp4':
  Metadata:
    audiodelay      : 0
    canSeekToEnd    : true
    encoder         : Lavf54.59.106
    Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 552x420 [SAR 1:1 DAR 46:35], q=-1--1, 12800 tbn, 25 tbc
    Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, s16, 128 kb/s
Stream mapping:
  Stream #0:0 (vp6a) -> scale (graph 0)
  Stream #1:0 (png) -> overlay:main (graph 0)
  overlay (graph 0) -> Stream #0:0 (libx264)
  Stream #0:1 -> #0:1 (mp3 -> libfaac)
Press [q] to stop, [?] for help
[Parsed_overlay_2 @ 0x7fe10ac1e680] Buffer queue overflow, dropping.
    Last message repeated 14 times
Buffer queue overflow, dropping.      0kB time=00:00:01.81 bitrate=   0.2kbits/s    
[Parsed_overlay_2 @ 0x7fe10ac1e680] Buffer queue overflow, dropping.
    Last message repeated 47 times
Buffer queue overflow, dropping.      0kB time=00:00:03.76 bitrate=   0.1kbits/s    
[Parsed_overlay_2 @ 0x7fe10ac1e680] Buffer queue overflow, dropping.
    Last message repeated 50 times
Buffer queue overflow, dropping.      0kB time=00:00:05.85 bitrate=   0.1kbits/s    
[Parsed_overlay_2 @ 0x7fe10ac1e680] Buffer queue overflow, dropping.
    Last message repeated 50 times
Buffer queue overflow, dropping.      0kB time=00:00:07.91 bitrate=   0.0kbits/s    
[Parsed_overlay_2 @ 0x7fe10ac1e680] Buffer queue overflow, dropping.
    Last message repeated 48 times
frame=    1 fps=0.4 q=28.0 Lsize=     162kB time=00:00:10.00 bitrate= 132.4kbits/s    
video:2kB audio:156kB subtitle:0 global headers:0kB muxing overhead 1.862288%
[libx264 @ 0x7fe10b042a00] frame I:1     Avg QP:26.10  size:  1776
[libx264 @ 0x7fe10b042a00] mb I  I16..4: 61.4% 35.3%  3.3%
[libx264 @ 0x7fe10b042a00] 8x8 transform intra:35.3%
[libx264 @ 0x7fe10b042a00] coded y,uvDC,uvAC intra: 18.6% 13.4% 2.2%
[libx264 @ 0x7fe10b042a00] i16 v,h,dc,p: 65% 23%  1% 11%
[libx264 @ 0x7fe10b042a00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 29% 23%  5%  3%  3%  4%  2%  4%
[libx264 @ 0x7fe10b042a00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 64% 16%  0%  0%  0%  0%  0%  1%
[libx264 @ 0x7fe10b042a00] i8c dc,h,v,p: 72% 19%  9%  0%
[libx264 @ 0x7fe10b042a00] kb/s:355.20

Strangely when I put it on the foreground, by setting it as the second parameter I don't get errors, but this is not what i want to achieve, the image has to be in the background.

Anyone has a solution?

This is my command word-wrapped which is easier to read:

ffmpeg -i test.flv -i test.png -filter_complex '[0:v]scale=max(552\, 420*iw/ih):-1[OUT1]; [OUT1]crop=552:420[OUT2];[1:v][OUT2]overlay[out]' -map [out] -map 0:a -t 00:00:10 -s 552x420 out.mp4

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You must loop your PNG file, since you are getting a Buffer queue overflow, dropping. error.

ffmpeg -i test.flv -loop 1 -i test.png -filter_complex '[0:v]scale=max(552\, 420*iw/ih):-1[OUT1]; [OUT1]crop=552:420[OUT2];[1:v][OUT2]overlay[out]' -map [out] -map 0:a -t 00:00:10 out.mp4

If that's not working it has something to do with the frame sizes. This Stack Overflow question might help you as well: Superimposing two videos onto a static image

share|improve this answer
    
Thank you Nick, that works great!! –  Ernie Apr 2 '13 at 10:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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