Repository navigation
HEVC Alpha
Apple VideoToolbox writes HEVC video with a transparent background: iPhone and iPad recordings, Keynote and Motion exports, HEVC stickers. The file has one hvc1 track that carries two layers. Layer 0 is the colour. Layer 1 is the alpha.
FFmpeg 9.0 decodes that alpha layer itself. This build has one patch on top: ffprobe reports yuva420p for the stream, not only for the frames.
Since: v1.0.39.
Two upstream changes are in FFmpeg 9.0. They keep the alpha layer when the decoder reads Apple's non-standard parameter extension, and they make the decoder pick the alpha pixel format. Without them the alpha layer is dropped and you get an opaque yuv420p picture.
The build script checks for both and skips them when they are there. It would apply them against an older FFmpeg. On 9.0 they are not part of this patch.
Upstream's stream parameters come from the file header. Probing never decodes a slice, so ffprobe -show_streams shows the base-layer format yuv420p, while -show_frames already shows yuva420p. The patch makes the header path report the alpha format as well.
| Command | Stock FFmpeg 9.0 | This build |
|---|---|---|
ffprobe -show_frames |
yuva420p |
yuva420p |
ffprobe -show_streams |
yuv420p |
yuva420p |
Only the advertised format changes. Hardware decoding negotiation is untouched.
# The stream-level pixel format of an alpha file
ffprobe -v error -select_streams v:0 -show_entries stream=pix_fmt -of csv=p=0 alpha.mov
# Take the alpha plane out as a grayscale video
ffmpeg -i alpha.mov -vf alphaextract -c:v libx264 mask.mp4The first command should print yuva420p (not run, see Verification).
The patch adds no options.
This is the weakest-tested page. The project has no HEVC alpha sample in its release tests. This page follows scripts/59-hevc-alpha-layer.sh and scripts/includes/hevc-alpha-stream-pixfmt.patch. It was not run in this documentation pass.
The patch file can be deleted to fall back to upstream behaviour. See also the upstream ticket #7965.
The patch applies to every platform build.
Users
Filters and components
- Filter-stemsplit
- Filter-lyricsalign
- Whisper-Language-Detection
- Whisper-Word-Timestamps
- Filter-trailingsilence
- Filter-keydetect
- Filter-beatdetect
- Filter-rubberband
- Muxer-Sprite-Sheet
- Muxer-Chapter-VTT
- Muxer-VOBsub
- Protocol-dvdread
- Protocol-OmniDrive
- Auto-Create-Directories
- AACS-and-BDplus
- HLS-Master-Playlist
- Subtitles-OCR
- HEVC-Alpha
Acceleration and codecs
Contributors