Convert mp4 to webm with transparency?

空扰寡人 提交于 2019-12-05 00:47:08

问题


I know how to convert mp4 to webm with ffmpeg:

ffmpeg -y -i me939371029.mp4 -r 30  out3.webm

But I'd like to use webm transparency. That guide uses Blender, but Blender's a desktop tool that's not easily automated and only outputs PNGs that must be converted to video. I'd like a command line app that accepts video in, a color, and a video out. E.g.:

some-app -i video.mp4 -transparent ff0000 -o video.webm

I'd be surprised if something like this wasn't already in ffmpeg, but I can't seem to find it.


回答1:


Assuming the color to be keyed out is 00ff00, use

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

In colorkey=0x00ff00:0.1:0.1

Parts are seperated by :. The first part is the key color. The color

0x00ff00

is green.

the 2nd is similarity

0.01 matches only the exact key color, while 1.0 matches everything.

and the 3rd is blend percentage

0.0 makes pixels either fully transparent, or not transparent at all.

Higher values result in semi-transparent pixels, with a higher transparency the more similar the pixels color is to the key color.

See the ffmpeg colorkey documentation



来源:https://stackoverflow.com/questions/34678964/convert-mp4-to-webm-with-transparency

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!