I'm trying to convert a video with alpha channel using FFmpeg, but the transparency information gets lost in the output.
Here is the input video (prores, yuva444p) detail with ffprobe:
Stream #0:1[0x2](und): Video: prores (4444) (ap4h / 0x68347061), yuva444p12le(bt709), 360x480, 73314 kb/s, 60.13 fps, 60 tbr, 600 tbn (default)
Metadata:
creation_time : 2019-05-21T21:23:03.000000Z
handler_name : Core Media Video
vendor_id : appl
encoder : Apple ProRes 4444
And my command is below:
ffmpeg -i alpha_prores.mov -c:v libvpx-vp9 -pix_fmt yuva420p -auto-alt-ref 0 out.webm
There is the output info:
Output #0, webm, to 'out.webm':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
com.apple.quicktime.creationdate: 2019-05-14T13:47:17-0700
com.apple.quicktime.location.ISO6709: +37.3367-122.0094/
com.apple.quicktime.make: Apple
com.apple.quicktime.model: iPhone X
com.apple.quicktime.software: 12.1.2
encoder : Lavf61.7.100
Stream #0:0(und): Video: vp9, yuva420p(tv, bt709, progressive), 360x480, q=2-31, 60 fps, 1k tbn (default)
Metadata:
creation_time : 2019-05-21T21:23:03.000000Z
handler_name : Core Media Video
vendor_id : appl
encoder : Lavc61.19.101 libvpx-vp9
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
We can see pix_fmt is still yuva420p, but after finished, I use ffprobe to check it, and the result changed!
Stream #0:0: Video: vp9 (Profile 0), yuv420p(tv, bt709, progressive), 360x480, SAR 1:1 DAR 3:4, 60 fps, 60 tbr, 1k tbn (default)
Metadata:
alpha_mode : 1
HANDLER_NAME : Core Media Video
VENDOR_ID : appl
ENCODER : Lavc61.19.101 libvpx-vp9
DURATION : 00:00:05.950000000
The pix_fmt turn to yuv420p, which means lose alpha channel. Also we can see there is an extra info in metadata alpha_mode: 1
.
By the way, the result webm video can display its transparent pixel correctly in browser.
When I try to overlay it on a mp4 video, transparent pixels turn to black pixels:
ffmpeg -i background.mp4 -i out.webm -filter_complex "[0][1]overlay=x=10:y=10" output2.mp4
And when I overlay the prores video on the same mp4, result is correct.
ffmpeg -i background.mp4 -i alpha_prores.mov -filter_complex "[0][1]overlay=x=10:y=10" output2.mp4
So I wonder the difference between yuva and alpha_mode:1.
And the reason why vp9 would lose alpha channel when overlay on a mp4 video.
It's better if you can provide other pixel format for my purpose(I want it can display correctly when overlay on mp4)!
Thanks!