使用 ffmpeg 在视频上叠加透明动画

使用 ffmpeg 在视频上叠加透明动画

总体任务是将动画信息图叠加在视频上。

我希望此视频中展示的结果http://www.youtube.com/watch?v=ZhMF3WD9pr0

00:08-00:11 上的精美动画半透明青色线条

弄清楚了如何使用 ImageMagick 的“转换”逐张叠加图像。效果不错,但速度很慢。

尝试根据此线程中的答案创建并叠加具有透明度的视频 stackoverflow.com/questions/644684/turn-image-sequence-into-video-with-transparency

还有一些即兴表演,例如:

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

然后从动画图片创建带有 alpha 通道的视频

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

并叠加视频

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

但这一切都会导致图像粗糙像素化在此处输入图片描述

希望您能给我一些提示,告诉我我遗漏了什么以及我还能做什么...

完整的 ffmpeg 输出:

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$ 

答案1

问题是由于64位 png.
用此方法解决方法 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

在这里我添加了-depth 8将 png 限制为 32 位而不是 64 位。

如果你检查你创建的 png,你会发现 test.png 的大小为 318.8kb,而 cyan.png 的大小为 17.3kb。此外,使用 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

但对于多重覆盖 png 来说,它是:

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

您会看到编解码器不同 - 一个是rgba64be,另一个是rgba64位 png可能是一个问题目前适用于 ffmpeg。

因此你的流程变成:

步骤 1-创建覆盖 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

第 2 步-创建背景图像。

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

步骤 3-创建覆盖影片。

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

步骤4-创建背景影片。

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

步骤 5——叠加覆盖影片。

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

电影现在应该没问题了。

不过,我还建议可以跳过创建覆盖影片这一步。只需使用:

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

答案2

看来 ffmpeg 不能很好地处理不同颜色的模糊半透明图元的叠加。

我想到的解决方法:

  • 创建多个视频。您需要的每种颜色一个。
  • 将它们按顺序叠加在背景视频上。

为了说明这一点,让我们创建一张由 3 个不同颜色的三角形叠加而成的图像。以及一张具有纯红色背景的图像。

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

现在我们创建两个 1 秒的电影并叠加它们

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

这是我们得到的低质量覆盖的框架: 覆盖框架质量较差

让我们为每种颜色制作三个不同的视频

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

然后将它们逐一叠加在我们的背景视频上

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

我们得到的是一幅更加美好的图景。 更高质量的覆盖框架

需要注意的是,这里的覆盖顺序非常重要!

相关内容