When preparing my master thesis presentation, I wanted to embed a video with a transparent background. While Keynote supports transparency in videos, it requires a specific encoding format to make this work correctly.
Step 1: Encode the Video with Transparency #
To create a transparent video, you’ll need to use the qtrle
codec—one of the few formats Keynote recognizes with an alpha channel. Assuming you have a folder of numbered PNG images (01.png
, 02.png
, etc.), you can encode them into a video using FFmpeg like so:
ffmpeg -framerate 2 -i %02d.png -vcodec qtrle movie.mov
-framerate 2
: Sets the frame rate to 2 frames per second. Adjust as needed.%02d.png
: Assumes files are named with two-digit numbers.-vcodec qtrle
: Specifies the QuickTime Animation codec, which supports transparency.
Step 2: Make Image Backgrounds Transparent #
If your PNG images have a white background you’d like to replace with transparency, you can use ImageMagick:
mogrify -transparent white *.png
This command will make all white pixels in the .png
files transparent.
Optionally, if your images have slight variations in white tones (due to compression or antialiasing), you can apply a fuzz factor:
mogrify -fuzz 2% -transparent white *.png
This treats colors within 2% of white as white for the purposes of making them transparent.
Tip: Use
convert
if you’re working with a single file. Usemogrify
to batch-process multiple files in-place.
For more details, see this helpful Stack Overflow post.