Search code examples
ffmpegtransparencyalphachannel

Compress Video While Preserving Alpha Channel


I have a video with a transparent background that is very large despite being only 6 seconds. I was hoping I could compress it with FFmpeg but everything I try seems to discard the alpha channel...

This code brings the file down from 33gb to 24mb:

ffmpeg -i "C:\Users\djcim\Desktop\Intro For Now\Video Intro.avi" -map 0 -c:v libx264 -preset slow ^
-crf 17 -acodec copy "C:\Users\djcim\Desktop\Intro For Now\Compressed.avi"

But as stated I lose the alpha channel, any ideas on how I could significantly compress my file while preserving the alpha channel?


Solution

  • There are various codecs that support alpha viz. qtrle, png, ffv1..etc

    Try those 3 to check which yields the best size. All are lossless. The first two only support RGB pixels, whereas FFV1 supports both RGB and YUV but few applications support it. PNG is the most widely compatible.

    e.g.

    ffmpeg -i "Video Intro.avi" -map 0 -c:v png -c:a copy "Compressed.avi"
    

    (Suggest using MOV container)