overlay transparent animation over video with ffmpeg

6

4

Overall task is to overlay animated infographics over video.

What I would like as a result shown in this video http://www.youtube.com/watch?v=ZhMF3WD9pr0

Nice animated semi-transparent cyan line on 00:08-00:11

Figured out how to do it by overlaying images one by one with "convert" from ImageMagick. Works fine but it's slow.

Tried to create and overlay video with transparency according to answers in this thread stackoverflow.com/questions/644684/turn-image-sequence-into-video-with-transparency

and some improvisations as well like:

ffmpeg -loop 1 -i ./frames/0253.png -r 30 -t 3 -pix_fmt rgba -vcodec png frame.mov

then create video with alpha channel from animated pics

ffmpeg -pattern_type glob -i 'angle/*.png' -r 30 -pix_fmt rgba -vcodec png z.mov

And overlay videos

ffmpeg -i frame.mov -i z.mov -filter_complex "[0:0][1:0]overlay[out]" -shortest -map [out] -pix_fmt rgba -vcodec png test.mov

But it all results in rough pixelized picture enter image description here

Would appreciate some hints on what am I missing here and what else could I do...

Full ffmpeg output:

alexandrov@ThinkPad-Edge:~/Documents/training 20150109/edit$ ffmpeg -loop 1 -i ./frames/0253.png -r 30 -t 3 -pix_fmt rgba -vcodec png frame.mov >> log.txt
ffmpeg version 2.5.git Copyright (c) 2000-2015 the FFmpeg developers
  built on Jan 11 2015 19:12:34 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
  configuration: --prefix=/home/alexandrov/ffmpeg_build --extra-cflags=-I/home/alexandrov/ffmpeg_build/include --extra-ldflags=-L/home/alexandrov/ffmpeg_build/lib --bindir=/home/alexandrov/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab
  libavutil      54. 16.100 / 54. 16.100
  libavcodec     56. 20.100 / 56. 20.100
  libavformat    56. 18.100 / 56. 18.100
  libavdevice    56.  3.100 / 56.  3.100
  libavfilter     5.  7.100 /  5.  7.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, png_pipe, from './frames/0253.png':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: png, rgb24, 1280x720 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 25 tbn, 25 tbc
File 'frame.mov' already exists. Overwrite ? [y/N] y
Output #0, mov, to 'frame.mov':
  Metadata:
    encoder         : Lavf56.18.100
    Stream #0:0: Video: png (png  / 0x20676E70), rgba, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 30 fps, 15360 tbn, 30 tbc
    Metadata:
      encoder         : Lavc56.20.100 png
Stream mapping:
  Stream #0:0 -> #0:0 (png (native) -> png (native))
Press [q] to stop, [?] for help
frame=    5 fps=0.0 q=0.0 size=    5321kB time=00:00:00.10 bitrate=435924
frame=    7 fps=6.6 q=0.0 size=    8869kB time=00:00:00.16 bitrate=435922
frame=   11 fps=5.9 q=0.0 size=   15964kB time=00:00:00.30 bitrate=435922
frame=   13 fps=5.4 q=0.0 size=   19512kB time=00:00:00.36 bitrate=435922
frame=   17 fps=5.5 q=0.0 size=   26607kB time=00:00:00.50 bitrate=435922
frame=   19 fps=5.1 q=0.0 size=   30154kB time=00:00:00.56 bitrate=435921
frame=   23 fps=5.3 q=0.0 size=   37249kB time=00:00:00.70 bitrate=435922
frame=   25 fps=5.0 q=0.0 size=   40797kB time=00:00:00.76 bitrate=435921
frame=   29 fps=5.1 q=0.0 size=   47892kB time=00:00:00.90 bitrate=435921
frame=   31 fps=4.9 q=0.0 size=   51439kB time=00:00:00.96 bitrate=435921
frame=   35 fps=4.9 q=0.0 size=   58534kB time=00:00:01.10 bitrate=435921
frame=   37 fps=4.9 q=0.0 size=   62082kB time=00:00:01.16 bitrate=435921
frame=   41 fps=4.9 q=0.0 size=   69177kB time=00:00:01.30 bitrate=435921
frame=   43 fps=4.8 q=0.0 size=   72725kB time=00:00:01.36 bitrate=435921
frame=   47 fps=4.9 q=0.0 size=   79820kB time=00:00:01.50 bitrate=435921
frame=   49 fps=4.7 q=0.0 size=   83367kB time=00:00:01.56 bitrate=435921
frame=   53 fps=4.9 q=0.0 size=   90462kB time=00:00:01.70 bitrate=435921
frame=   55 fps=4.7 q=0.0 size=   94010kB time=00:00:01.76 bitrate=435921
frame=   60 fps=4.8 q=0.0 size=  102879kB time=00:00:01.93 bitrate=435921
frame=   63 fps=4.7 q=0.0 size=  108200kB time=00:00:02.03 bitrate=435921
frame=   66 fps=4.7 q=0.0 size=  113521kB time=00:00:02.13 bitrate=435921
frame=   69 fps=4.7 q=0.0 size=  118843kB time=00:00:02.23 bitrate=435921
frame=   73 fps=4.7 q=0.0 size=  125938kB time=00:00:02.36 bitrate=435921
frame=   78 fps=4.7 q=0.0 size=  134807kB time=00:00:02.53 bitrate=435921
frame=   81 fps=4.7 q=0.0 size=  140128kB time=00:00:02.63 bitrate=435921
frame=   84 fps=4.7 q=0.0 size=  145449kB time=00:00:02.73 bitrate=435921
frame=   87 fps=4.7 q=0.0 size=  150770kB time=00:00:02.83 bitrate=435921
frame=   90 fps=4.7 q=0.0 size=  156092kB time=00:00:02.93 bitrate=435921
frame=   90 fps=4.6 q=0.0 Lsize=  159640kB time=00:00:03.00 bitrate=435924.5kbits/s dup=15 drop=0    
video:159639kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000662%


alexandrov@ThinkPad-Edge:~/Documents/training 20150109/edit$ ffmpeg -pattern_type glob -i 'angle/*.png' -r 30 -pix_fmt rgba -vcodec png z.mov >> log.txt
ffmpeg version 2.5.git Copyright (c) 2000-2015 the FFmpeg developers
  built on Jan 11 2015 19:12:34 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
  configuration: --prefix=/home/alexandrov/ffmpeg_build --extra-cflags=-I/home/alexandrov/ffmpeg_build/include --extra-ldflags=-L/home/alexandrov/ffmpeg_build/lib --bindir=/home/alexandrov/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab
  libavutil      54. 16.100 / 54. 16.100
  libavcodec     56. 20.100 / 56. 20.100
  libavformat    56. 18.100 / 56. 18.100
  libavdevice    56.  3.100 / 56.  3.100
  libavfilter     5.  7.100 /  5.  7.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, image2, from 'angle/*.png':
  Duration: 00:00:03.24, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: png, rgba64be, 1280x720 [SAR 72:72 DAR 16:9], 25 fps, 25 tbr, 25 tbn, 25 tbc
File 'z.mov' already exists. Overwrite ? [y/N] y
Output #0, mov, to 'z.mov':
  Metadata:
    encoder         : Lavf56.18.100
    Stream #0:0: Video: png (png  / 0x20676E70), rgba, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 30 fps, 15360 tbn, 30 tbc
    Metadata:
      encoder         : Lavc56.20.100 png
Stream mapping:
  Stream #0:0 -> #0:0 (png (native) -> png (native))
Press [q] to stop, [?] for help
frame=    6 fps=0.0 q=0.0 size=     363kB time=00:00:00.13 bitrate=22310.
frame=   12 fps= 11 q=0.0 size=    1105kB time=00:00:00.33 bitrate=27156.
frame=   18 fps= 11 q=0.0 size=    1803kB time=00:00:00.53 bitrate=27698.
frame=   24 fps= 10 q=0.0 size=    2576kB time=00:00:00.73 bitrate=28777.
frame=   30 fps= 10 q=0.0 size=    3282kB time=00:00:00.93 bitrate=28809.
frame=   36 fps= 10 q=0.0 size=    4100kB time=00:00:01.13 bitrate=29634.
frame=   42 fps= 10 q=0.0 size=    4829kB time=00:00:01.33 bitrate=29672.
frame=   48 fps= 10 q=0.0 size=    5586kB time=00:00:01.53 bitrate=29844.
frame=   54 fps= 10 q=0.0 size=    6441kB time=00:00:01.73 bitrate=30443.
frame=   59 fps= 10 q=0.0 size=    7154kB time=00:00:01.90 bitrate=30846.
frame=   65 fps= 10 q=0.0 size=    8010kB time=00:00:02.10 bitrate=31244.
frame=   69 fps= 10 q=0.0 size=    8580kB time=00:00:02.23 bitrate=31471.
frame=   75 fps= 10 q=0.0 size=    9435kB time=00:00:02.43 bitrate=31763.
frame=   81 fps= 10 q=0.0 size=   10290kB time=00:00:02.63 bitrate=32012.
frame=   87 fps= 10 q=0.0 size=   11146kB time=00:00:02.83 bitrate=32225.
frame=   93 fps= 10 q=0.0 size=   12001kB time=00:00:03.03 bitrate=32410.
frame=   97 fps= 10 q=0.0 Lsize=   12857kB time=00:00:03.23 bitrate=32575.6kbits/s dup=16 drop=0    
video:12856kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.009313%


alexandrov@ThinkPad-Edge:~/Documents/training 20150109/edit$ ffmpeg -i frame.mov -i z.mov -filter_complex "[0:0][1:0]overlay[out]" -shortest -map [out] -pix_fmt rgba -vcodec png test.mov >> log.txt
ffmpeg version 2.5.git Copyright (c) 2000-2015 the FFmpeg developers
  built on Jan 11 2015 19:12:34 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
  configuration: --prefix=/home/alexandrov/ffmpeg_build --extra-cflags=-I/home/alexandrov/ffmpeg_build/include --extra-ldflags=-L/home/alexandrov/ffmpeg_build/lib --bindir=/home/alexandrov/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab
  libavutil      54. 16.100 / 54. 16.100
  libavcodec     56. 20.100 / 56. 20.100
  libavformat    56. 18.100 / 56. 18.100
  libavdevice    56.  3.100 / 56.  3.100
  libavfilter     5.  7.100 /  5.  7.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'frame.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf56.18.100
  Duration: 00:00:03.00, start: 0.000000, bitrate: 435924 kb/s
    Stream #0:0(eng): Video: png (png  / 0x20676E70), rgba, 1280x720 [SAR 1:1 DAR 16:9], 435921 kb/s, 30 fps, 30 tbr, 15360 tbn, 15360 tbc (default)
    Metadata:
      handler_name    : DataHandler
      encoder         : Lavc56.20.100 png
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'z.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf56.18.100
  Duration: 00:00:03.23, start: 0.000000, bitrate: 32568 kb/s
    Stream #1:0(eng): Video: png (png  / 0x20676E70), rgba, 1280x720 [SAR 1:1 DAR 16:9], 32572 kb/s, 30 fps, 30 tbr, 15360 tbn, 15360 tbc (default)
    Metadata:
      handler_name    : DataHandler
      encoder         : Lavc56.20.100 png
Output #0, mov, to 'test.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf56.18.100
    Stream #0:0: Video: png (png  / 0x20676E70), rgba, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 30 fps, 15360 tbn, 30 tbc (default)
    Metadata:
      encoder         : Lavc56.20.100 png
Stream mapping:
  Stream #0:0 (png) -> overlay:main
  Stream #1:0 (png) -> overlay:overlay
  overlay -> Stream #0:0 (png)
Press [q] to stop, [?] for help
frame=    3 fps=0.0 q=0.0 size=    1717kB time=00:00:00.03 bitrate=421888
frame=    5 fps=3.8 q=0.0 size=    5212kB time=00:00:00.10 bitrate=427001
frame=    7 fps=3.7 q=0.0 size=    8720kB time=00:00:00.16 bitrate=428613
frame=    8 fps=3.3 q=0.0 size=   10475kB time=00:00:00.20 bitrate=429061
frame=   11 fps=3.7 q=0.0 size=   15746kB time=00:00:00.30 bitrate=429972
frame=   13 fps=3.7 q=0.0 size=   19264kB time=00:00:00.36 bitrate=430381
frame=   13 fps=3.2 q=0.0 size=   19264kB time=00:00:00.36 bitrate=430381
frame=   15 fps=3.1 q=0.0 size=   22781kB time=00:00:00.43 bitrate=430672
frame=   17 fps=3.1 q=0.0 size=   26297kB time=00:00:00.50 bitrate=430857
frame=   19 fps=3.0 q=0.0 size=   29814kB time=00:00:00.56 bitrate=431000
frame=   21 fps=3.1 q=0.0 size=   33331kB time=00:00:00.63 bitrate=431122
frame=   23 fps=3.1 q=0.0 size=   36848kB time=00:00:00.70 bitrate=431228
frame=   25 fps=3.1 q=0.0 size=   40367kB time=00:00:00.76 bitrate=431328
frame=   27 fps=3.2 q=0.0 size=   43884kB time=00:00:00.83 bitrate=431399
frame=   29 fps=3.2 q=0.0 size=   47402kB time=00:00:00.90 bitrate=431466
frame=   31 fps=3.2 q=0.0 size=   50923kB time=00:00:00.96 bitrate=431548
frame=   33 fps=3.2 q=0.0 size=   54449kB time=00:00:01.03 bitrate=431655
frame=   36 fps=3.3 q=0.0 size=   59741kB time=00:00:01.13 bitrate=431822
frame=   38 fps=3.3 q=0.0 size=   63267kB time=00:00:01.20 bitrate=431903
frame=   40 fps=3.3 q=0.0 size=   66794kB time=00:00:01.26 bitrate=431981
frame=   43 fps=3.3 q=0.0 size=   72080kB time=00:00:01.36 bitrate=432055
frame=   46 fps=3.4 q=0.0 size=   77365kB time=00:00:01.46 bitrate=432117
frame=   48 fps=3.4 q=0.0 size=   80889kB time=00:00:01.53 bitrate=432159
frame=   50 fps=3.4 q=0.0 size=   84414kB time=00:00:01.60 bitrate=432197
frame=   53 fps=3.5 q=0.0 size=   89700kB time=00:00:01.70 bitrate=432248
frame=   55 fps=3.4 q=0.0 size=   93224kB time=00:00:01.76 bitrate=432279
frame=   57 fps=3.4 q=0.0 size=   96749kB time=00:00:01.83 bitrate=432308
frame=   58 fps=3.3 q=0.0 size=   98511kB time=00:00:01.86 bitrate=432322
frame=   60 fps=3.4 q=0.0 size=  102035kB time=00:00:01.93 bitrate=432348
frame=   63 fps=3.4 q=0.0 size=  107322kB time=00:00:02.03 bitrate=432383
frame=   64 fps=3.4 q=0.0 size=  109084kB time=00:00:02.06 bitrate=432394
frame=   66 fps=3.4 q=0.0 size=  112608kB time=00:00:02.13 bitrate=432415
frame=   69 fps=3.4 q=0.0 size=  117895kB time=00:00:02.23 bitrate=432445
frame=   71 fps=3.4 q=0.0 size=  121419kB time=00:00:02.30 bitrate=432463
frame=   73 fps=3.4 q=0.0 size=  124943kB time=00:00:02.36 bitrate=432480
frame=   75 fps=3.4 q=0.0 size=  128468kB time=00:00:02.43 bitrate=432496
frame=   77 fps=3.4 q=0.0 size=  131992kB time=00:00:02.50 bitrate=432511
frame=   79 fps=3.4 q=0.0 size=  135516kB time=00:00:02.56 bitrate=432526
frame=   81 fps=3.4 q=0.0 size=  139041kB time=00:00:02.63 bitrate=432540
frame=   83 fps=3.4 q=0.0 size=  142565kB time=00:00:02.70 bitrate=432553
frame=   85 fps=3.4 q=0.0 size=  146089kB time=00:00:02.76 bitrate=432565
frame=   87 fps=3.4 q=0.0 size=  149614kB time=00:00:02.83 bitrate=432577
frame=   89 fps=3.4 q=0.0 size=  153138kB time=00:00:02.90 bitrate=432588
frame=   91 fps=3.4 q=0.0 size=  156663kB time=00:00:02.96 bitrate=432599
frame=   91 fps=3.3 q=0.0 Lsize=  160188kB time=00:00:03.03 bitrate=432613.9kbits/s dup=0 drop=6    
video:160187kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000884%
alexandrov@ThinkPad-Edge:~/Documents/training 20150109/edit$ 

Adrian

Posted 2015-01-22T20:04:49.400

Reputation: 73

If you are going to be using a mov to overlay, why not set the codec to quicktime with alpha? The codec is qtrle. (Instead of vcodec png). – Rajib – 2015-01-23T11:11:55.060

Answers

5

The problem arises due to 64bit png.
Use this to solve the problem in method 1:

convert -size 1280x720 xc:transparent -background transparent \
    -channel RGBA -fill '#0FF8' \
    -draw 'polygon 200, 600, 200, 20, 600, 50, 600, 50' \
    -fill '#0008' -draw 'polygon 200, 660, 200, 40, 660, 70, 660, 70' \
    -fill '#fFF8' -draw 'polygon 200, 500, 200, 00, 500, 30, 500, 30' \
    -channel RGBA -depth 8 -blur '10x5' test.png

Here I added -depth 8 to restrict the png to 32 bits rather than 64.

If you check the pngs you created, size of test.png is 318.8kb and that of cyan.png is 17.3kb. Also, testing with ffmpeg:

ffmpeg -i cyan.png
...
Input #0, png_pipe, from 'cyan.png':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: png, rgba, 1280x720 [SAR 72:72 DAR 16:9], 25 tbr, 25 tbn, 25 tbc

But for the multiple overlay png it is:

ffmpeg -i test.png
...
Input #0, png_pipe, from 'test.png':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: png, rgba64be, 1280x720 [SAR 72:72 DAR 16:9], 25 tbr, 25 tbn, 25 tbc

You see that the codecs are different- one is rgba64be and the other is rgba. The 64bit png may be a problem for ffmpeg for now.

So your flow becomes:

Step 1- create the overlay png.

convert -size 1280x720 xc:transparent -background transparent \
    -channel RGBA -fill '#0FF8' \
    -draw 'polygon 200, 600, 200, 20, 600, 50, 600, 50' -fill '#0008' \
    -draw 'polygon 200, 660, 200, 40, 660, 70, 660, 70' -fill '#fFF8' \
    -draw 'polygon 200, 500, 200, 00, 500, 30, 500, 30' -channel RGBA \
    -depth 8 -blur '10x5' test.png

Step 2- create the background image.

convert -size 1280x720 xc:yellow -background yellow -channel RGBA gnd.png

Step 3- create the overlay movie.

ffmpeg -loop 1 -i test.png -t 1 -pix_fmt argb -vcodec qtrle z.mov

Step 4- create the background movie.

ffmpeg -loop 1 -i gnd.png -t 1 -pix_fmt argb -vcodec qtrle gnd.mov

Step 5 - overlay the overlay movie.

ffmpeg -vcodec qtrle -i gnd.mov -vcodec qtrle -i z.mov \
    -filter_complex "[0:0][1:0]overlay=format=rgb[out]" -shortest \
    -map [out] -vcodec qtrle test.mov

The movie should be fine now.

However I would also suggest that it is possible to skip the creation of an overlay movie. Just use:

ffmpeg -i gnd.mov -i test.png \
    -filter_complex "[0:0][1:0]overlay=format=rgb[out]" \
    -map [out] -vcodec qtrle test.mov

Rajib

Posted 2015-01-22T20:04:49.400

Reputation: 2 406

1By default the overlay filter will output yuv420, so when working with RGB you can add the overlay format option such as overlay=format=rgb to avoid any issues caused by the RGB to YUV conversion. – llogan – 2015-01-24T20:31:40.310

"-depth 8" worked like a charm!

Overlaying direct png image surely works way better and if the point is to overlay static picture it's best solution to stick with. I was struggling with some animation here so it was not an option. Frame by frame overlay or video on video. First was slow and with second issues described in this question I was stuck into. – Adrian – 2015-01-25T00:08:07.717

1

Seems like ffmpeg can't very well handle overlay of blurred semi-transparent primitives of different color.

Workaround I've come up with:

  • Create several videos. One for each color you need.
  • Overlay them over background video sequentialy.

To illustrate this let's create image with 3 overlayed triangles of different color. And an image with solid red background.

convert -size 1280x720 xc:transparent -background transparent -channel RGBA -fill '#0FF8' -draw 'polygon 200, 600, 200, 20, 600, 50, 600, 50' -fill '#0008' -draw 'polygon 200, 660, 200, 40, 660, 70, 660, 70' -fill '#fFF8' -draw 'polygon 200, 500, 200, 00, 500, 30, 500, 30' -channel RGBA -blur '10x5' test.png
convert -size 1280x720 xc:yellow -background yellow -channel RGBA gnd.png

Now we create two 1 sec movies from each and overlay them

ffmpeg -loop 1 -i test.png -t 1 -pix_fmt argb -vcodec qtrle z.mov
ffmpeg -loop 1 -i gnd.png -t 1 -pix_fmt argb -vcodec qtrle gnd.mov
ffmpeg -vcodec qtrle -i gnd.mov -vcodec qtrle -i z.mov -filter_complex "[0:0][1:0]overlay[out]" -shortest -map [out] -vcodec qtrle -pix_fmt argb test.mov

here's a frame from poor quality overlay we've got: poor quality overlay frame

Lets create three different videos for each color

convert -size 1280x720 xc:transparent -background transparent -channel RGBA -fill '#0FF8' -draw 'polygon 200, 600, 200, 20, 600, 50, 600, 50' -channel RGBA -blur '10x5' cyan.png
convert -size 1280x720 xc:transparent -background transparent -channel RGBA -fill '#0008' -draw 'polygon 200, 660, 200, 40, 660, 70, 660, 70' -channel RGBA -blur '10x5' black.png
convert -size 1280x720 xc:transparent -background transparent -channel RGBA -fill '#fFF8' -draw 'polygon 200, 500, 200, 00, 500, 30, 500, 30' -channel RGBA -blur '10x5' white.png

convert -size 1280x720 xc:red gnd.png

ffmpeg -loop 1 -i cyan.png -t 1 -pix_fmt argb -vcodec qtrle cyan.mov
ffmpeg -loop 1 -i white.png -t 1 -pix_fmt argb -vcodec qtrle white.mov
ffmpeg -loop 1 -i black.png -t 1 -pix_fmt argb -vcodec qtrle black.mov

ffmpeg -loop 1 -i gnd.png -t 1 -pix_fmt argb -vcodec qtrle gnd.mov

And overlay them one by one over our background video

ffmpeg -i gnd.mov -i cyan.mov -i white.mov -i black.mov -filter_complex "[0:0][2:0]overlay[tmp1]; [tmp1][3:0]overlay[tmp2]; [tmp2][1:0]overlay[out]" -shortest -map [out] -vcodec qtrle -pix_fmt argb good.mov

What we've got is a way better picture. higher quality overlay frame

Important note is that overlay sequence matter a lot here!

Adrian

Posted 2015-01-22T20:04:49.400

Reputation: 73

quality on real video is still not perfect but way better than initial attempts http://i62.tinypic.com/xe4eoz.png

– Adrian – 2015-01-23T20:04:01.140

Please use StackExchange to host images, rather than external links. Thanks! – Ben Richards – 2015-01-23T20:37:04.717

Could you explain further? I understood your original question to have only 1 overlay. Are you saying the problem happens only when there are multiple overlays? – Rajib – 2015-01-24T05:04:13.917

@Rajib problem was detected when single overlay video had two or more overlayed primitives with transparency. In case shown in initial question there are cyan base lines and text and black and white copy of it shifted by several pixels to add some shape effect to them. It is best visible with text. there're black border on the right and white on the left. With lines there is workaround just drawing them another way so the white, cyan and black don't overlay. But with text they would've overlay anyway. Also overlaying video was important cause the point was displaying moving lines not static. – Adrian – 2015-01-25T00:25:20.463