Skip to content

Video editing with Python

Fix reading of transparent webm not working with ffmpeg by default

osaajani788f1f4f15f8
diff --git a/moviepy/video/io/ffmpeg_reader.py b/moviepy/video/io/ffmpeg_reader.py
index b22aa2b6..347d71d4 100644
--- a/moviepy/video/io/ffmpeg_reader.py
+++ b/moviepy/video/io/ffmpeg_reader.py
@@ -98,6 +98,12 @@ class FFMPEG_VideoReader:
else:
i_arg = ["-i", self.filename]
+ # For webm video with transparent layer, force libvpx-vp9 as ffmpeg native webm
+ # decoder dont decode alpha layer
+ # (see https://www.reddit.com/r/ffmpeg/comments/fgpyfb/help_with_webm_with_alpha_channel/)
+ if self.depth == 4 and self.filename[-5:] == '.webm' :
+ i_arg = ["-c:v", "libvpx-vp9"] + i_arg
+
cmd = (
[FFMPEG_BINARY]
+ i_arg
@@ -117,6 +123,7 @@ class FFMPEG_VideoReader:
"-",
]
)
+
popen_params = cross_platform_popen_params(
{
"bufsize": self.bufsize,