title: FFmpeg using png with tranparency and exclusion blending mode
body: <p>I'm trying to use the exclusion blending mode to blend together a video and a png with transparency. I've looked around quite a bit but I can't find a solution that works for me. Here's the ffmpeg command:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>ffmpeg -i movie.mkv -i text_white_bg_trans.png -filter_complex\
    "[1:v]setsar=sar=1,format=rgba[txt]; [0:v]format=rgba[mo]; [mo][txt]blend=all_mode='exclusion'"  out_exclusion.mkv</code></pre>
  </div>
  </div>
  
  Edit: and the console output:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>ffmpeg version 3.0.2 Copyright (c) 2000-2016 the FFmpeg developers
    built with Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
    configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-avresample --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libtheora --enable-libschroedinger --enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libsoxr --enable-libspeex --enable-libass --enable-libbluray --enable-lzma --enable-gnutls --enable-fontconfig --enable-libfreetype --enable-libfribidi --disable-indev=jack --disable-outdev=xv --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/clang --enable-vda --enable-videotoolbox --arch=x86_64 --enable-yasm --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid
    libavutil      55. 17.103 / 55. 17.103
    libavcodec     57. 24.102 / 57. 24.102
    libavformat    57. 25.100 / 57. 25.100
    libavdevice    57.  0.101 / 57.  0.101
    libavfilter     6. 31.100 /  6. 31.100
    libavresample   3.  0.  0 /  3.  0.  0
    libswscale      4.  0.100 /  4.  0.100
    libswresample   2.  0.101 /  2.  0.101
    libpostproc    54.  0.100 / 54.  0.100
  Input #0, matroska,webm, from 'movie.mkv':
    Metadata:
      ENCODER         : Lavf57.25.100
    Duration: 00:00:11.88, start: 0.000000, bitrate: 5143 kb/s
      Stream #0:0: Video: h264 (High), yuv420p, 1640x1232, SAR 1:1 DAR 205:154, 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
      Metadata:
        ENCODER         : Lavc57.24.102 libx264
        DURATION        : 00:00:11.880000000
  Input #1, png_pipe, from 'text_white_bg_trans.png':
    Duration: N/A, bitrate: N/A
      Stream #1:0: Video: png, rgba(pc), 1640x1232, 25 tbr, 25 tbn, 25 tbc
  File 'out_exclusion.mkv' already exists. Overwrite ? [y/N] y
  No pixel format specified, yuv444p for H.264 encoding chosen.
  Use -pix_fmt yuv420p for compatibility with outdated media players.
  [libx264 @ 0x7fb10a01e200] using SAR=1/1
  [libx264 @ 0x7fb10a01e200] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
  [libx264 @ 0x7fb10a01e200] profile High 4:4:4 Predictive, level 4.0, 4:4:4 8-bit
  [libx264 @ 0x7fb10a01e200] 264 - core 148 - 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=4 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, matroska, to 'out_exclusion.mkv':
    Metadata:
      encoder         : Lavf57.25.100
      Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv444p, 1640x1232 [SAR 1:1 DAR 205:154], q=-1--1, 25 fps, 1k tbn, 25 tbc (default)
      Metadata:
        encoder         : Lavc57.24.102 libx264
      Side data:
        unknown side data type 10 (24 bytes)
  Stream mapping:
    Stream #0:0 (h264) -&gt; format
    Stream #1:0 (png) -&gt; setsar
    blend -&gt; Stream #0:0 (libx264)
  Press [q] to stop, [?] for help
  frame=   24 fps=0.0 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A speed=  frame=   47 fps= 40 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A speed=  frame=   61 fps= 36 q=28.0 size=      96kB time=00:00:00.12 bitrate=6567.3kbitsframe=   70 fps= 32 q=28.0 size=     264kB time=00:00:00.48 bitrate=4513.9kbitsframe=   83 fps= 30 q=28.0 size=     498kB time=00:00:01.00 bitrate=4079.5kbitsframe=   95 fps= 29 q=28.0 size=     691kB time=00:00:01.48 bitrate=3827.5kbitsframe=  106 fps= 28 q=28.0 size=     896kB time=00:00:01.92 bitrate=3823.7kbitsframe=  118 fps= 27 q=28.0 size=    1132kB time=00:00:02.40 bitrate=3863.7kbitsframe=  130 fps= 26 q=28.0 size=    1338kB time=00:00:02.88 bitrate=3806.1kbitsframe=  142 fps= 26 q=28.0 size=    1588kB time=00:00:03.36 bitrate=3871.7kbitsframe=  154 fps= 25 q=28.0 size=    1808kB time=00:00:03.84 bitrate=3856.9kbitsframe=  166 fps= 25 q=28.0 size=    2062kB time=00:00:04.32 bitrate=3910.9kbitsframe=  178 fps= 24 q=28.0 size=    2328kB time=00:00:04.80 bitrate=3972.8kbitsframe=  190 fps= 24 q=28.0 size=    2620kB time=00:00:05.28 bitrate=4064.7kbitsframe=  203 fps= 24 q=28.0 size=    2886kB time=00:00:05.80 bitrate=4076.0kbitsframe=  215 fps= 24 q=28.0 size=    3132kB time=00:00:06.28 bitrate=4085.9kbitsframe=  226 fps= 24 q=28.0 size=    3357kB time=00:00:06.72 bitrate=4092.5kbitsframe=  238 fps= 24 q=28.0 size=    3589kB time=00:00:07.20 bitrate=4083.9kbitsframe=  250 fps= 23 q=28.0 size=    3794kB time=00:00:07.68 bitrate=4047.3kbitsframe=  260 fps= 23 q=28.0 size=    3978kB time=00:00:08.08 bitrate=4032.7kbitsframe=  272 fps= 23 q=28.0 size=    4212kB time=00:00:08.56 bitrate=4031.0kbitsframe=  284 fps= 23 q=28.0 size=    4453kB time=00:00:09.04 bitrate=4035.3kbitsframe=  295 fps= 23 q=28.0 size=    4632kB time=00:00:09.48 bitrate=4002.9kbitsframe=  297 fps= 20 q=-1.0 Lsize=    5559kB time=00:00:11.80 bitrate=3859.4kbits/s speed=0.808x    
  video:5556kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.053747%
  [libx264 @ 0x7fb10a01e200] frame I:2     Avg QP:21.70  size: 56001
  [libx264 @ 0x7fb10a01e200] frame P:178   Avg QP:23.12  size: 24833
  [libx264 @ 0x7fb10a01e200] frame B:117   Avg QP:25.78  size:  9886
  [libx264 @ 0x7fb10a01e200] consecutive B-frames: 29.3% 49.8% 14.1%  6.7%
  [libx264 @ 0x7fb10a01e200] mb I  I16..4:  9.5% 75.0% 15.5%
  [libx264 @ 0x7fb10a01e200] mb P  I16..4:  4.0% 14.8%  1.0%  P16..4: 43.3% 12.0%  4.5%  0.0%  0.0%    skip:20.4%
  [libx264 @ 0x7fb10a01e200] mb B  I16..4:  0.6%  1.9%  0.1%  B16..8: 48.5%  4.2%  0.3%  direct: 0.6%  skip:43.8%  L0:42.5% L1:55.6% BI: 1.9%
  [libx264 @ 0x7fb10a01e200] 8x8 transform intra:74.8% inter:85.5%
  [libx264 @ 0x7fb10a01e200] coded y,u,v intra: 31.3% 0.0% 0.0% inter: 15.0% 0.0% 0.0%
  [libx264 @ 0x7fb10a01e200] i16 v,h,dc,p: 30% 32% 13% 25%
  [libx264 @ 0x7fb10a01e200] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 22% 32%  3%  4%  3%  6%  3%  3%
  [libx264 @ 0x7fb10a01e200] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 33% 16%  3%  4%  3%  9%  4%  2%
  [libx264 @ 0x7fb10a01e200] Weighted P-Frames: Y:0.0% UV:0.0%
  [libx264 @ 0x7fb10a01e200] ref P L0: 72.2% 17.9%  7.5%  2.5%
  [libx264 @ 0x7fb10a01e200] ref B L0: 90.9%  8.6%  0.5%
  [libx264 @ 0x7fb10a01e200] ref B L1: 98.6%  1.4%
  [libx264 @ 0x7fb10a01e200] kb/s:3830.94</code></pre>
  </div>
  </div>
  
  Edit: Here's a frame from the output. 
  <a href="https://i.stack.imgur.com/ufc9N.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ufc9N.png" alt=""></a>
  The output video is B&amp;W rather than the original color (not sure why). The rectangle in the image is located where there is a block of text on a png with a transparent background. The png is the same size as the video.</p>
  
  <p>I'm expecting something more like this:
  <a href="https://i.stack.imgur.com/shC8O.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/shC8O.png" alt="enter image description here"></a></p>
  
  <p>@Mulvya suggestion fixed the issue with color but I'm still seeing some problems with transparency being handled. I'm attaching a few different images below that each create different problems. All created in Photoshop CC (therein may lie the problem).</p>
  
  <p>A transparent background with a separate text layer that is then exported by Save->png, Photoshop appears to merge these two layers but differently than when "merge layers" is chosen before export. The exported image looks like the B&amp;W image I posted above but with color.</p>
  
  <p>The in the second I merge the layers before exporting. It appears the entire image is treated as white.</p>
  
  <p>In the third I draw "hello" on a transparent layer with a "soft" brush using different grays then export. Transparent areas are rendered as white, gray or translucent areas opaque or with a strange dithering "effect."</p>
  
  <p>It seems I'm moving outside the realm of StackOverflow, but I'm not sure where this post would be better suited.
  1
  <a href="https://i.stack.imgur.com/1Cy6G.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1Cy6G.png" alt="1"></a>
  2
  <a href="https://i.stack.imgur.com/D9dpt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D9dpt.png" alt="2"></a>
  3
  <a href="https://i.stack.imgur.com/HpceO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HpceO.png" alt="3"></a></p>