[FFmpeg-user] alphamerge filter use problem

Tim Willison timbot at oddlystudios.com
Sun Apr 7 21:44:07 CEST 2013


Hi, this is my first question ever to a mailing list (or anywhere!).
I have been using ffmpeg for about a year and a half and have figured out
many things on my own but I'm stumped regarding the alphaextract and
alphamerge filters.
I am able to get the proper result every time with images, but have yet to
succeed with videos. I have tried many formats and searched extensively but
have not found a single documented case of someone successfully using this
filter combination and sharing an example. The documentation on the
ffmpeg-filters page is very sparse, and does not give any details of what
formats/codecs are supported.

I think this filter would be very useful if I can figure it out.

Step 1 - alphaextract
This seems to always work, and produces a grayscale video as expected. In
my tests I have used rgba video, as well as quicktime with animation codec
(bgra).

Step 2 - applying the extracted alpha
This works every time for images. However while the encode completes with
video it never provides the masking expected by mapping the extracted alpha
information to the alpha channel of the target video. In my tests with
still images, I found that the output format must be a format that supports
an alpha channel, and I have tried several with video (which I determined
by looking at the source code of the filter).

My command (taken from the docs) looks like this:

ffmpeg -i timbotundelay.mp4 -vf "movie=timbotoverlayextracted.mov [alpha];
[in][alpha] alphamerge [out]" -an -y -pix_fmt rgba -vcodec png composite.mov
ffmpeg version git-2013-04-06-1177416 Copyright (c) 2000-2013 the FFmpeg
developers
  built on Apr  6 2013 17:31:47 with gcc 4.6.1 (Ubuntu/Linaro
4.6.1-9ubuntu3)
  configuration: --enable-gpl --enable-libass --enable-libfaac
--enable-libfdk-aac --enable-libmp3lame --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-libspeex --enable-librtmp
--enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264
--enable-nonfree --enable-version3 --enable-libfreetype
--enable-filter=drawtext
  libavutil      52. 25.100 / 52. 25.100
  libavcodec     55.  2.100 / 55.  2.100
  libavformat    55.  1.100 / 55.  1.100
  libavdevice    55.  0.100 / 55.  0.100
  libavfilter     3. 49.100 /  3. 49.100
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'timbotundelay.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42mp41
    creation_time   : 2013-04-07 18:35:55
  Duration: 00:00:04.97, start: 0.000000, bitrate: 241 kb/s
    Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p,
1280x720 [SAR 1:1 DAR 16:9], 35 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc
    Metadata:
      creation_time   : 2013-04-07 18:35:55
      handler_name    : ?Mainconcept Video Media Handler
    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo,
fltp, 189 kb/s
    Metadata:
      creation_time   : 2013-04-07 18:35:55
      handler_name    : #Mainconcept MP4 Sound Media Handler
Output #0, mov, to 'composite.mov':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42mp41
    encoder         : Lavf55.1.100
    Stream #0:0(eng): Video: png (png  / 0x20676E70), rgba, 1280x720 [SAR
1:1 DAR 16:9], q=2-31, 200 kb/s, 15360 tbn, 30 tbc
    Metadata:
      creation_time   : 2013-04-07 18:35:55
      handler_name    : ?Mainconcept Video Media Handler
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> png)
Press [q] to stop, [?] for help
frame=  151 fps= 64 q=0.0 Lsize=    1952kB time=00:00:05.03
bitrate=3177.5kbits/s dup=2 drop=0
video:1951kB audio:0kB subtitle:0 global headers:0kB muxing overhead
0.067323%

After this, I see only my red background (timbotundelay.mp4) and no alpha
applied.
Thanks so much to anyone who can help me out here. I'm running out of
things to try. I'd particularly like to see how people are using this
filter successfully.


More information about the ffmpeg-user mailing list