Convert a video to transparent using ffmpeg
10,321
Use
ffmpeg -i video.mp4 -filter_complex
"[0]split[m][a];
[a]geq='if(lt(lum(X,Y),16),0,255)',hue=s=0[al];
[m][al]alphamerge,format=yuva420p"
-c:v libvpx output.webm
See here for how to use this file in Chrome.
As of now, VP8 alpha playback is behind a flag, so you have to either enable it in about:flags or set the command line flag --enable-vp8-alpha-playback when you start Chrome. When the flag is enabled, alpha playback also works with MediaSource.
Related videos on Youtube
![somya bhargava](https://lh4.googleusercontent.com/-Ob5BQa3Ptds/AAAAAAAAAAI/AAAAAAAAAK8/30BLGfNBh_k/photo.jpg?sz=256)
Author by
somya bhargava
A tech loving person, loves to learn about new technologies going on. Working and managing a team in Rocketium in a MERN stack and handling devops also. Love learning from new developers and sharing my knowledge wherever possible.
Updated on September 18, 2022Comments
-
somya bhargava almost 2 years
Want to convert the black part in the video to transparent so can be used in modern browsers to overlay
Presently doing things using html canvas
-
somya bhargava almost 8 yearsUsing html canvas have created two videos one grayscale and one with rgb just copying the rgb value from grayscale video to the alpha value of rgb video means in bytes R, G, B, A putting R,Gand B from video with color and A value from color of grayscale video
-
Gyan almost 8 yearsWhich format? I only know of VP8/VP9, which at present, support alpha channel for web playback. See basic approach here.
-
somya bhargava almost 8 yearsInput files mp4 and output any format
-