1

I have an alpha.mp4 (alpha matte video) and a color.mp4 (color video). How do I use ffmpeg to make a transparent HEVC (.mov) video?

I can combine with ffmpeg to make a .webm file following the instruction here: https://www.unscreen.com/api under "Convert unpacked Pro Bundle to WEBM video with transparency"

From here I got

ffmpeg -y -i edited.mp4 -i matte.mp4 -f lavfi -i color=c=black:s=320x240 -filter_complex "[1:v]scale=320:240,setsar=1:1,split[vs][alpha];[0:v][vs]alphamerge[vt];[2:v][vt]overlay=shortest=1[rgb];[rgb][alpha]alphamerge" -shortest -c:v hevc_videotoolbox -allow_sw 1 -alpha_quality 0.75 -vtag hvc1 -pix_fmt yuva420p -an output.mov

which returns

Incompatible pixel format 'yuva420p' for codec 'hevc_videotoolbox', auto-selecting format 'bgra'
zsh: illegal hardware instruction ffmpeg -y -i color.mp4 -i alpha.mp4 -f lavfi -i color=c=black:s=720x1280

Running ffmpeg -h encoder=hevc_videotoolbox gives me Supported pixel formats: videotoolbox_vld nv12 yuv420p bgra p010le –

1
  • I ran into similar situation when trying to convert PNG sequence to MOV with HEVC encoding on MacOS. I haven't been able to find a fix for this yet. Commented Jan 30, 2023 at 12:10

1 Answer 1

2

Use the following command to learn the encoders potential settings:

ffmpeg -h encoder=hevc_videotoolbox

In the case of converting alpha channel stills to Safari compatible transparent videos, here is an example that works for me using .tif files.

ffmpeg -framerate 30 -i ./input/file_%03d.tif -c:v hevc_videotoolbox -tag:v hvc1 -pix_fmt yuva444p -profile:v main -realtime true -b:v 8M -alpha_quality 1 -color_primaries 1 -color_trc 1 -colorspace 1 -crf 15 -vsync 0 -preset veryslow -s 1920x1920 -an -movflags +faststart -y -r 30 -y ./output/out.mp4

Note that there are adjustable values in crf, -v:b (bitrate), framerates, etc...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .