FFMPEG - Merging Videos with Transparency

Deadly 提交于 2019-12-03 13:36:09

问题


I am trying to merge two videos together, both have transparency, using the command

ffmpeg.exe -i person2.mov -vf "[in] scale=iw/2:ih/2,fade=out:300:30:alpha=1, pad=2*iw:ih [left]; movie=person2.mov, scale=iw/2:ih/2,fade=out:300:30:alpha=1 [right]; [left][right] overlay=main_w/3:0,fade=out:300:30:alpha=1 [out]" -b:v 768k Output_people.mov

By doing that I get the following output:

http://i263.photobucket.com/albums/ii122/Fernando461/Untitled.png

As you can see, it was possible to get the two videos to be on top of each other. But then, when I try to merge this video (Output_people.mov) with another video, it doesn't have the same transparency. Is it possible to keep transparency in the outcome?

Edit 1:

This is the output I get: https://www.dropbox.com/s/gpid1pptfio31gd/ffmpeg-20130701-193206.log

And by "it doesn't have the same transparecy" I meant that the background is black instead of being transparent, so if I put one video on top of each other, the one in the back is covered by a black part of the one in the front.

Edit 2: Adding -vcodec qtrle to the code worked. Thanks mark4o!


回答1:


You did not specify a video codec for the output, so it is using the default video codec for .mov files which is H.264 (libx264 encoder). However H.264 does not support an alpha channel. If you want transparency in your output video you will need to specify an output video codec that supports an alpha channel, such as the one used for your input, i.e. QuickTime Animation RLE (qtrle). To do this, add the option -c:v qtrle before the output file name. Another codec that supports an alpha channel and can be stored in .mov files is png.

You can check the list of encoders supported by your ffmpeg with ffmpeg -encoders. A command like ffmpeg -h encoder=qtrle will list information specific to that encoder, including the supported pixel formats. A pixel format that includes the string argb, rgba, abgr, bgra, gbra, or yuva has an alpha channel.



来源:https://stackoverflow.com/questions/17415651/ffmpeg-merging-videos-with-transparency

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