Hi,
I have a transparent background webm video and I want to make it smaller but I cant seem to find an application that allows me to compress it without losing its transparent background. What can I use for this task?
Thank you.
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 18 of 18
Thread
-
-
Not much you can do in terms of terms of making it smaller in filesize and retaining alpha channel -
If it's lossless webm, then you can use lossy webm profile but it will be chroma subsampled (sharp color edges will become blurred)
If it's lossy profile webm already, you can use a lower quality webm but it will obviously be lower in quality
There is a hevc variant that supports alpha channel, but it's only supported by macs
Or depending on your scenario or how you are planning to use it, you can use 2 streams with separate alpha -
Web - as in embedding ?
There aren't really any other decent options for web that preserve transparency and that is compatible with most browsers except webm , such as using vp9 compression
You could use ffmpeg, libvpx-vp9
pixel format would be yuva420p ("a" to retain the alpha channel)
If you have a specific target filesize (bitrate) in mind, then use 2-pass mode. Otherwise use a higher -crf value with -b:v 0 until the quality is too low for you
https://trac.ffmpeg.org/wiki/Encode/VP9
AV1 in the future should support alpha channel, but currently does not officially yet (although AVIF does, the AV1 based animated image format - but it's temporal compression is not as good as vp9 - because AVIF is really a still image format) -
I have avidemux and virtualdub, so if I use Vp9 codec I can reduce the size with those and keep the transparency?
-
As poisondeathray mentioned above you could try
Code:ffmpeg -i your.webm -c:v libvpx-vp9 -crf 30 -b:v 0 -pix_fmt yuva420p -c:a copy output.webm
-
Thank you but that didnt preserve the transparency. It adds a white background.
-
Are you using a recent ffmpeg version ?
How are you viewing it ? Post a cut stream copy of your source -
Yes, I just downloaded the latest version. This is the file I tried to compress by using the command ProWo provided but it only added a white background. You can test the transparency here: https://rotato.app/tools/transparent-video
-
Code:
ffmpeg -i input.webm -c:v libvpx-vp9 -crf 30 -vf "colorkey=0x000000:0.1:0.1,format=yuva420p" -pix_fmt yuva420p -c:a copy output.webm
users currently on my ignore list: deadrats, Stears555 -
You have to specify the decoder as libvpx-vp9 (as in input option, before the -i) . FFmpeg's default decoder doesn't read the alpha channel
And it doesn't hurt to tag the alpha mode metadata, it can be more compatible with some applications, and there is no down side
Code:ffmpeg -c:v libvpx-vp9 -i aa73a2.webm -c:v libvpx-vp9 -crf 30 -b:v 0 -pix_fmt yuva420p -metadata:s:v:0 alpha_mode="1" -c:a copy output.webm
-
Thanks, this time the alpha transparency was preserved. I guess the alpha_mode="1" line did the trick. However I tried the same on a similar sample but it wont get compressed. In fact, it increases in size. I applied the same exact command so I dont get it. I understand libvpx-vp9 is the codec, -crf 30 is the frame rate? I dont know whats the -b:v 0 line and as for yuva420p I guess its the video dimensions. This is my sample:
-
-crf is essentially the "quality" . It means "constant rate factor" . Higher values yield smaller filesizes, lower quality . Try 35 or 40. 35 gives slightly smaller filesize than a2.webm. You can look into advanced vp9 encoding settings as well
-b:v 0 is required for ffmpeg libvpx-vp9, to select crf mode. You can use other rate control methods outlined in the link earlier.
yuva420p is the pixel format . YUV 4:2:0 , "a" means alpha channel.
Similar Threads
-
How to extract audio from *.ts file without re-encoding or losing quality
By vlp_007 in forum AudioReplies: 2Last Post: 9th Dec 2021, 03:14 -
How to decrypt webm video file?
By webcyb in forum Video Streaming DownloadingReplies: 3Last Post: 25th Oct 2021, 04:01 -
How To Use ffmpeg to merge audio_only.webm with video_only.webm
By carlarogers in forum Video ConversionReplies: 3Last Post: 4th Aug 2020, 08:21 -
mp4/mkv to webm (I see lots of posts going the other way but not TO webm)
By AshleyQuick in forum Video ConversionReplies: 9Last Post: 10th Aug 2018, 09:19 -
Compress video to a certain file size?
By kingmustard123 in forum EditingReplies: 8Last Post: 13th Aug 2017, 10:11