ffmpegwasm / ffmpegwasm/ffmpeg.wasm
Support for yuva420p with HEVC in libx265 for Transparent Video in iOS Safari
- Dominant language
- C
- Stars
- 17.8k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
### Is your feature request related to a problem? Please describe.
Currently, **HEVC (libx265)** does not support encoding videos with alpha transparency using the `yuva420p` pixel format. This limitation prevents encoding transparent videos with HEVC for **iOS Safari playback** when transparency is required. As a result, HEVC cannot be used as an efficient compression format for videos that must maintain alpha channels.
For example, using the following **FFmpeg command** results in an error:
```javascript
ffmpeg.exec([
"-i", "Coffe bean_with sound_alpha.mov",
"-vf", "scale=ceil(iw/2)*2:ceil(ih/2)*2",
"-c:v", "hevc",
"-pix_fmt", "yuva420p",
"-b:v", "2M",
"-crf", "15",
"-tag:v", "hvc1",
"output_ios.mov"
]);
```
The issue arises because **libx265** cannot process the `yuva420p` pixel format, leading to failed encoding attempts. Transparent videos encoded using HEVC fail to work as intended on **iOS Safari**.
---
### Describe the solution you'd like
It would be ideal if **libx265** supported the `yuva420p` pixel format for encoding HEVC videos with transparency (alpha channels). This would enable transparent videos to be encoded with a highly efficient compression algorithm (**HEVC/H.265**) while preserving alpha channels, ensuring compatibility with **iOS Safari**, which supports HEVC with alpha transparency.
To achieve this, the following enhancements are necessary:
- **Support for encoding with `yuva420p`:** Enabling the `yuva420p` pixel format for **libx265** would allow HEVC to handle videos with transparency.
- **iOS Safari Compatibility:** Ensuring that transparent videos encoded with `yuva420p` in **libx265** render properly on **iOS Safari**, which already supports HEVC with alpha channels.
The error occurs due to libx265's inability to process yuva420p, leading to a failed encoding attempt. Transparent videos encoded using this method do not work as intended on iOS Safari.
---
### Describe alternatives you've considered
1. **Use of ProRes 4444:**
While ProRes 4444 supports transparency, it is less efficient than HEVC, resulting in significantly larger file sizes. ProRes is also less suitable for streaming scenarios where smaller file sizes are critical.
2. **Use of VP9 with alpha:**
VP9 supports transparency (`yuva420p`) and is compatible with some modern browsers. However, VP9 lacks widespread adoption on iOS and does not benefit from the hardware acceleration available for HEVC on iOS devices.
---
### Additional context
**iOS Safari** supports **HEVC (H.265)** but does not natively process transparency in HEVC videos due to the lack of `yuva420p` support in **libx265**. Adding this support would enable more efficient and widely supported delivery of transparent HEVC video content, improving streaming performance and compatibility across devices.
Contributor guide
Assessment
This issue has not been assessed yet.