将Alpha与Alpha转换为带有Alpha的VP9 Webm使用ffmpeg

时间:2016-01-18 13:44:43

标签: video ffmpeg webm

我正在尝试将带有Alpha透明度的 mov 转换为带有Alpha透明度的 webm ,如here所示。我按照here解释的步骤无效。

this answer我可以删除视频中的所有黑色,从而使其透明但这不是我需要的,因为我已经有了一个透明的 mov 并希望将其转换为透明的 webm 格式。

ffmpeg -i input.mp4 -c:v libvpx -vf "colorkey=0x000000:0.1:0.1,format=yuva420p" out.webm

这是我要转换为具有透明度的webm的视频的ffprobe输出。

built with Apple LLVM version 7.0.2 (clang-700.1.81)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/2.8.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-libfreetype --enable-libtheora --enable-libvorbis --enable-libvpx --enable-librtmp --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libass --enable-ffplay --enable-libspeex --enable-libschroedinger --enable-libfdk-aac --enable-libopus --enable-frei0r --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags=-I/usr/local/Cellar/openjpeg/1.5.2_1/include/openjpeg-1.5 --enable-nonfree --enable-vda
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mov':
  Metadata:
    major_brand     : qt
    minor_version   : 0
    compatible_brands: qt
    creation_time   : 2016-01-17 16:04:07
    encoder         : Mac OS X v? (AVF 1046.9.1, CM 1731.15.20, x86_64)
    encoder-eng     : Mac OS X v? (AVF 1046.9.1, CM 1731.15.20, x86_64)
  Duration: 00:00:06.63, start: 0.000000, bitrate: 63966 kb/s
    Stream #0:0(eng): Video: prores (ap4h / 0x68347061), yuva444p10le(bt470bg/smpte240m/bt709), 1920x1080, 63963 kb/s, 25.03 fps, 25 tbr, 600 tbn, 600 tbc (default)
    Metadata:
      creation_time   : 2016-01-17 16:04:07
      handler_name    : Core Media Data Handler
      encoder         : Apple ProRes 4444

我也尝试过以下对我不起作用的命令。

ffmpeg -y -i input.mov -c:v libvpx-vp9 -b:v 2000k -pass 1 -an -f webm output.webm

我在Mac上使用版本2.8.4的ffmpeg,与brew一起安装。 2.8.5是最新版本。

4 个答案:

答案 0 :(得分:9)

尝试

ffmpeg -i input.mov -c:v libvpx -pix_fmt yuva420p out.webm

答案 1 :(得分:8)

2016-07-13以来,可以使用Alpha通道( VP9a )对 VP9 / webm 视频进行编码。但是,您在此处使用的命令将创建 VP8a 视频。假设您在该日期之后收到了 ffmpeg 的副本,您只需将libvpx更改为libvpx-vp9即可。您也不需要yuva420p转换(默认情况下已选中)。

答案 2 :(得分:2)

WebM-alpha仅针对VP8定义。它现在对VP9来说根本不起作用。

答案 3 :(得分:1)

所有其他解决方案均产生了质量不佳的视频。请确保您根据自己的喜好定义比特率。我从1M更改为2M,并感到满意。

ffmpeg -i "Model 1 V1.mov" -f webm -c:v libvpx -b:v 2M -acodec libvorbis -auto-alt-ref 0 model1v3.webm -hide_banner

如果您使用的是After Effects或Premiere Pro,则还有plugin,可在Adobe Media Encoder中使用。