Opened 3 years ago
Closed 6 months ago
#10901 closed defect (fixed)
HEVC with alpha to PNG does not maintain alpha
| Reported by: | Jozef Chutka | Owned by: | |
|---|---|---|---|
| Priority: | normal | Component: | undetermined |
| Version: | 6.1 | Keywords: | Hevc alpha |
| Cc: | Blocked By: | ||
| Blocking: | Reproduced by developer: | no | |
| Analyzed by developer: | no |
Description
When converting hevc.mp4 with alpha into PNG, the alpha information is not respected, producing opaque PNG.
How to reproduce:
% ffmpeg -i hevc.mp4 -vframes 1 output.png
hevc.mp4 was created from source image with alpha channel and seems to have the alpha properly encoded:
ffmpeg -i source.png -vcodec hevc_videotoolbox -r 1 -t 1 -vtag hvc1 -alpha_quality 1 -y hevc.mp4
Following https://trac.ffmpeg.org/ticket/7965 which refers to https://patchwork.ffmpeg.org/project/ffmpeg/patch/tencent_5F1F4DA9CFDF5521A752B8C9161A4D23A007@qq.com/ it seems hevcdec has some kind of decoding support for alpha channel... is it hidden behind some command line flag?
Attachments (3)
Change History (6)
by , 3 years ago
| Attachment: | source.png added |
|---|
by , 3 years ago
by , 3 years ago
| Attachment: | output.png added |
|---|
comment:1 by , 2 years ago
comment:2 by , 6 months ago
videotoolbox-generated files might need this commit:
https://source.ffmpeg.org/gitweb/ffmpeg.git/commit/eedf8f0165fe6523be692c5a91ebf6744808335d
I checked with patched ffmpeg 8.1 and files from
https://developer.apple.com/documentation/avfoundation/using-hevc-video-with-alpha
and ffmpeg cli correctly encodes alpha channel into png, it seems?
comment:3 by , 6 months ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
videotoolbox-generated files might need this commit:
Not might, they do need it. as Apple early version of that alpha hevc encoder is buggy and it violates its own specs...
And yes, you can see that alpha exists in the new png file
ffplay -i fafwqa.png -vf extractplanes=r ffplay -i fafwqa.png -vf extractplanes=a



I suspect this is waiting for this: https://trac.ffmpeg.org/ticket/7965
My understanding, in short: The integrated x265 decoder in FFMPEG doesn't yet have support for alpha channel data, so it gets lost during decoding and the internal bitstream is YUV and not YUVA. When the decoder starts supporting alpha data, I think converting to PNG frames with alpha will probably just work.