VideoHelp Forum

+ Reply to Thread
Results 1 to 18 of 18
Thread
  1. 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.
    Quote Quote  
  2. 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
    Quote Quote  
  3. I plan it to use it on the web so I would prefer a smaller file if possible.
    Quote Quote  
  4. I think it's possible with premiere pro
    Quote Quote  
  5. Originally Posted by supercain View Post
    I plan it to use it on the web so I would prefer a smaller file if possible.
    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)
    Quote Quote  
  6. I have avidemux and virtualdub, so if I use Vp9 codec I can reduce the size with those and keep the transparency?
    Quote Quote  
  7. Originally Posted by supercain View Post
    I have avidemux and virtualdub, so if I use Vp9 codec I can reduce the size with those and keep the transparency?

    Both do not preserve the alpha channel on export. I do not see any options to keep the alpha channel for vdub or avidemux using vp9 in the settings
    Quote Quote  
  8. Any online solution that can do it? I tried many but none of them worked.
    Quote Quote  
  9. 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
    Quote Quote  
  10. Thank you but that didnt preserve the transparency. It adds a white background.
    Quote Quote  
  11. Are you using a recent ffmpeg version ?

    How are you viewing it ? Post a cut stream copy of your source
    Quote Quote  
  12. 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
    Image Attached Files
    Quote Quote  
  13. 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
    works fine here,...
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  14. Can I see the output please?
    Quote Quote  
  15. 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
    Image Attached Files
    Quote Quote  
  16. 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:
    Image Attached Files
    Quote Quote  
  17. Originally Posted by supercain View Post
    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.
    Quote Quote  
  18. I finally managed to compress it the right way. Thank you so much guys.
    Quote Quote  



Similar Threads