Home > Software design >  How can I convert a webm file with alpha channel to a hevc encoded file that will play in safari on
How can I convert a webm file with alpha channel to a hevc encoded file that will play in safari on

Time:09-21

I've got a webm file with transparency : https://itype.techforge.com.au/assets/videos/upshot/module1/NP_1A.webm

I'm trying to convert it into something that will play in the video element of a web page in the Safari browser on an IPad.

An example of a file that works is : https://rotato.netlify.app/alpha-demo/movie-hevc.mov

My attempts at doing this conversion have all failed. 3rd party apps seem to all lose the alpha channel.

On my mac I tried ffmpeg

ffmpeg -i input.webm -c:v hevc_videotoolbox -allow_sw 1 -alpha_quality 0.75 -vtag hvc1 output.mov

However, while this resulted in a file that reported a codec of MPEG-H Part2/HEVC (H.265) (hvc1) the resulting file still has a black background instead of a transparent one.

ffmpeg log : https://pastebin.com/DMM9y5PU

CodePudding user response:

The built-in, default decoder for VP9 currently does not support alpha / transparency. Manually use the decoder libvpx-vp9:

ffmpeg -c:v libvpx-vp9 -i input.webm -c:v hevc_videotoolbox -allow_sw 1 -alpha_quality 0.75 -vtag hvc1 -movflags  faststart output.mov

Your ffmpeg needs to be compiled with --enable-libvpx for this to work.

  • Related