首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >FFMPEG混合屏幕两个libvpx-vp9webm yuva420p视频文件看起来不正确

FFMPEG混合屏幕两个libvpx-vp9webm yuva420p视频文件看起来不正确
EN

Stack Overflow用户
提问于 2022-11-30 13:21:16
回答 1查看 24关注 0票数 0

我试图筛选混合两个libvpx-VP9WebM文件,这样在FFMPEG中混合出来的文件看起来是正确的。下面的示例以两个rgba输入文件为例,用像素格式yuva420p将它们循环到libvpx-VP9WebM文件中几秒钟。然后尝试使用FFMPEG混合它们。然后,我输出这些框架,以形象化它在这个堆栈溢出帖子中的外观。

我有这两个输入rgba pngs (圆圈和皮卡丘)

我创建了两个libvpx-vp9WebM文件,如下所示:-

代码语言:javascript
运行
复制
ffmpeg -loop 1 -i circle_50_rgba.png -c:v libvpx-vp9 -t 2 -pix_fmt yuva420p circle_libvpx-vp9_yuva420p.webm

ffmpeg -loop 1 -i pikachu_rgba.png -c:v libvpx-vp9 -t 2 -pix_fmt yuva420p pikachu_libvpx-vp9_yuva420p.webm

然后,我尝试将这两个libvpx-vp9 webm文件混合在一起,如下所示:-

代码语言:javascript
运行
复制
ffmpeg -y -c:v libvpx-vp9 -i circle_libvpx-vp9_yuva420p.webm -c:v libvpx-vp9 -i pikachu_libvpx-vp9_yuva420p.webm -filter_complex "[1:v][0:v]blend=all_mode=screen" pikachu_reverse_all_mode_screened_onto_circle_both_yuva420p.webm

从这样的画面中提取出一个框架

代码语言:javascript
运行
复制
ffmpeg  -c:v libvpx-vp9 -i pikachu_reverse_all_mode_screened_onto_circle_both_yuva420p.webm -frames:v 1  pikachu_reverse_all_mode_screened_onto_circle_from_yuva420p.png

看起来是这样的-

如果我在没有all_mode的情况下这样做,像这样

代码语言:javascript
运行
复制
ffmpeg -y -c:v libvpx-vp9 -i circle_libvpx-vp9_yuva420p.webm -c:v libvpx-vp9 -i pikachu_libvpx-vp9_yuva420p.webm -filter_complex "[1:v][0:v]blend=screen" pikachu_reverse_screened_onto_circle_both_yuva420p.webm

然后提取png,这样我们就能看到它,就像这样:-

代码语言:javascript
运行
复制
ffmpeg  -c:v libvpx-vp9 -i pikachu_reverse_screened_onto_circle_both_yuva420p.webm -frames:v 1  pikachu_reverse_screened_onto_circle_from_yuva420p.png

它给出了这个输出:-

这也是不正确的,因为白色部分的圆圈应该是完全白色的屏幕混合。我们不应该在白色的部分看到皮卡丘微弱的黄色轮廓。

它应该是这样的:-

这是完整的日志如下:-

代码语言:javascript
运行
复制
ffmpeg -y -c:v libvpx-vp9 -i circle_libvpx-vp9_yuva420p.webm -c:v libvpx-vp9 -i pikachu_libvpx-vp9_yuva420p.webm -filter_complex "[1:v][0:v]blend=screen" pikachu_reverse_screened_onto_circle_both_yuva420p.webm
ffmpeg version 4.2.7-0ubuntu0.1 Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1)
  configuration: --prefix=/usr --extra-version=0ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
[libvpx-vp9 @ 0x55d5b1f34680] v1.8.2
    Last message repeated 1 times
Input #0, matroska,webm, from 'circle_libvpx-vp9_yuva420p.webm':
  Metadata:
    ENCODER         : Lavf58.29.100
  Duration: 00:00:02.00, start: 0.000000, bitrate: 19 kb/s
    Stream #0:0: Video: vp9 (Profile 0), yuva420p(tv), 50x50, SAR 1:1 DAR 1:1, 25 fps, 25 tbr, 1k tbn, 1k tbc (default)
    Metadata:
      alpha_mode      : 1
      ENCODER         : Lavc58.54.100 libvpx-vp9
      DURATION        : 00:00:02.000000000
[libvpx-vp9 @ 0x55d5b1f854c0] v1.8.2
    Last message repeated 1 times
Input #1, matroska,webm, from 'pikachu_libvpx-vp9_yuva420p.webm':
  Metadata:
    ENCODER         : Lavf58.29.100
  Duration: 00:00:02.00, start: 0.000000, bitrate: 29 kb/s
    Stream #1:0: Video: vp9 (Profile 0), yuva420p(tv), 50x50, SAR 1:1 DAR 1:1, 25 fps, 25 tbr, 1k tbn, 1k tbc (default)
    Metadata:
      alpha_mode      : 1
      ENCODER         : Lavc58.54.100 libvpx-vp9
      DURATION        : 00:00:02.000000000
[libvpx-vp9 @ 0x55d5b1f38940] v1.8.2
[libvpx-vp9 @ 0x55d5b1f49440] v1.8.2
Stream mapping:
  Stream #0:0 (libvpx-vp9) -> blend:bottom
  Stream #1:0 (libvpx-vp9) -> blend:top
  blend -> Stream #0:0 (libvpx-vp9)
Press [q] to stop, [?] for help
[libvpx-vp9 @ 0x55d5b1f49440] v1.8.2
[libvpx-vp9 @ 0x55d5b1f38940] v1.8.2
[libvpx-vp9 @ 0x55d5b1f80c40] v1.8.2
Output #0, webm, to 'pikachu_reverse_screened_onto_circle_both_yuva420p.webm':
  Metadata:
    encoder         : Lavf58.29.100
    Stream #0:0: Video: vp9 (libvpx-vp9), yuva420p, 50x50 [SAR 1:1 DAR 1:1], q=-1--1, 200 kb/s, 25 fps, 1k tbn, 25 tbc (default)
    Metadata:
      encoder         : Lavc58.54.100 libvpx-vp9
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame=   50 fps=0.0 q=0.0 Lsize=       7kB time=00:00:01.96 bitrate=  29.3kbits/s speed=33.2x    
video:4kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 96.711426%

我还试着转换到rgba,比如:-

代码语言:javascript
运行
复制
ffmpeg -y -c:v libvpx-vp9 -i circle_libvpx-vp9_yuva420p.webm -c:v libvpx-vp9 -i pikachu_libvpx-vp9_yuva420p.webm -filter_complex "[0:v]format=pix_fmts=rgba[zero];[1:v]format=pix_fmts=rgba[one];[one][zero]blend=screen" pikachu_reverse_screened_all_mode_onto_circle_after_rgba_conversion_webm.webm

然而,这一结果也会在白色圆圈内出现黄色,应该是白色的。

我想知道我需要做些什么,以使这两个webm libvpx 9视频文件的混合看起来正确,就像上面一样。

注意:我需要保留alpha通道,因为有时资产有透明的alpha通道。在上面的例子中,资产碰巧有不透明的alpha通道。

EN

回答 1

Stack Overflow用户

发布于 2022-11-30 18:40:36

秘密是使用gbrp来转换文件和all_mode,如下所示:

代码语言:javascript
运行
复制
ffmpeg -y -c:v libvpx-vp9 -i circle_libvpx-vp9_yuva420p.webm -c:v libvpx-vp9 -i pikachu_libvpx-vp9_yuva420p.webm -filter_complex "[0:v]format=pix_fmts=gbrp[zero];[1:v]format=pix_fmts=gbrp[one];[one][zero]blend=all_mode=screen" pikachu_reverse_screened_all_mode_onto_circle_after_gbrp_conversion_webm.webm

如果你像这样提取帧:-

代码语言:javascript
运行
复制
fmpeg -c:v libvpx-vp9 -i pikachu_reverse_screened_all_mode_onto_circle_after_gbrp_conversion_webm.webm -frames:v 1  pikachu_reverse_screened_all_mode_onto_circle_after_gbrp_conversion_png.png

你会发现它是这样的:-

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74628494

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档