Table of Contents
Convert MOV with Alpha Channel to WEBM with Alpha Channel
This guide explains how to convert MOV files with transparency, also known as an alpha channel, into WEBM files with an alpha channel. The conversion is done with FFmpeg using a PowerShell script on Windows.
Goal
The script converts all .mov files from this folder:
C:\temp\ffmpeg
The finished .webm files are saved in the same folder.
Example:
C:\temp\ffmpeg\A14-PETER.mov
becomes:
C:\temp\ffmpeg\A14-PETER.webm
The WEBM file is created with these settings:
Format: WEBM Codec: VP9 Alpha channel: yes Frame rate: 25 fps Scan type: progressive Bitrate: approx. 4 Mbit/s
Create the Folder
If the folder does not already exist, create it as follows:
- Open Windows Explorer.
- Go to:
C:\
- Create a new folder there:
temp
- Open the
tempfolder. - Create another folder inside it:
ffmpeg
The full path should then be:
C:\temp\ffmpeg
Alternatively, the folder can be created in PowerShell:
New-Item -ItemType Directory -Path "C:\temp\ffmpeg" -Force
Prepare FFmpeg
For the script to work, ffmpeg.exe must be located in this folder:
C:\temp\ffmpeg\ffmpeg.exe
The folder should therefore contain at least this file:
C:\temp\ffmpeg\ffmpeg.exe
Optionally, ffprobe.exe can also be placed in the same folder. This is useful for checking files later.
Copy MOV Files into the Folder
Copy all MOV files that should be converted to:
C:\temp\ffmpeg
Example:
C:\temp\ffmpeg\A14-PETER (vMix - Output 3).mov
The script automatically processes all files with the extension:
.mov
Create the PowerShell Script
Open PowerShell and enter:
notepad C:\temp\ffmpeg\convert.ps1
If asked whether the file should be created, confirm with Yes.
Then paste the following content into Notepad:
$ErrorActionPreference = "Stop" $folder = "C:\temp\ffmpeg" $ffmpegLocal = Join-Path $folder "ffmpeg.exe" if (Test-Path $ffmpegLocal) { $ffmpeg = $ffmpegLocal } else { $ffmpeg = "ffmpeg" } $movFiles = Get-ChildItem -Path $folder -Filter "*.mov" -File if ($movFiles.Count -eq 0) { Write-Host "No .mov files found in $folder." exit 0 } foreach ($file in $movFiles) { $input = $file.FullName $output = Join-Path $folder ($file.BaseName + ".webm") Write-Host "" Write-Host "Converting:" Write-Host " Input : $input" Write-Host " Output: $output" $cmd = "`"$ffmpeg`" -y -i `"$input`" -vf `"yadif=0:-1:0,fps=25`" -c:v libvpx-vp9 -pix_fmt yuva420p -auto-alt-ref 0 -b:v 4M -minrate 4M -maxrate 4M -crf 25 `"$output`"" cmd /c $cmd if ($LASTEXITCODE -eq 0) { Write-Host "OK: $output" } else { Write-Host "ERROR: FFmpeg exit code $LASTEXITCODE for $input" } } Write-Host "" Write-Host "All conversions completed."
Save the file.
The script path is then:
C:\temp\ffmpeg\convert.ps1
Run the Script
Go to the folder:
C:\temp\ffmpeg
The file convert.ps1 should be located there.
Right-click the file and choose Run with PowerShell.
If the conversion starts, everything is working correctly.
OR:
Open PowerShell and change to the folder:
cd C:\temp\ffmpeg
If PowerShell blocks script execution, enter this first:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
Then start the script:
.\convert.ps1
The script now searches for all .mov files in the folder and creates .webm files from them.
What Happens During the Conversion?
This line is the most important part of the script:
$cmd = "`"$ffmpeg`" -y -i `"$input`" -vf `"yadif=0:-1:0,fps=25`" -c:v libvpx-vp9 -pix_fmt yuva420p -auto-alt-ref 0 -b:v 4M -minrate 4M -maxrate 4M -crf 25 `"$output`""
Meaning of the most important parameters:
| Parameter | Meaning |
|---|---|
-y | Overwrites existing WEBM files without asking |
-i “$input” | Specifies the MOV input file |
-vf “yadif=0:-1:0,fps=25” | Converts the video to progressive and sets it to 25 fps |
-c:v libvpx-vp9 | Uses the VP9 codec for WEBM |
-pix_fmt yuva420p | Preserves the alpha channel for transparency |
-auto-alt-ref 0 | Important so that alpha works correctly with VP9 |
-b:v 4M | Sets the target bitrate to 4 Mbit/s |
-minrate 4M | Sets the minimum bitrate to 4 Mbit/s |
-maxrate 4M | Sets the maximum bitrate to 4 Mbit/s |
-crf 25 | Quality value for VP9 |
“$output” | Name of the generated WEBM file |
Check the Result
After a successful conversion, the WEBM file is located in the same folder as the MOV file.
Example:
C:\temp\ffmpeg\A14-PETER (vMix - Output 3).webm
To check whether the file contains alpha channel information, run this in PowerShell:
.\ffmpeg.exe -i "C:\temp\ffmpeg\A14-PETER (vMix - Output 3).webm"
In the output, the video stream should contain a hint like this:
alpha_mode
or a pixel format such as:
yuva420p
This indicates that the file was saved with an alpha channel.
Common Errors
Error Message: “No .mov files found”
This means that there is no MOV file in the folder:
C:\temp\ffmpeg
Solution: copy the MOV files into this folder.
Error Message: “ffmpeg is not recognized”
This means that ffmpeg.exe is missing.
Solution: copy ffmpeg.exe into this folder:
C:\temp\ffmpeg
The WEBM File Has No Transparency
Possible causes:
- The original MOV file does not contain an alpha channel.
- The MOV file had already been exported without alpha.
- The player does not display WEBM alpha correctly.
For testing, open the WEBM file in an application that supports WEBM with alpha.
Quick Workflow
- Create the folder:
C:\temp\ffmpeg
- Place
ffmpeg.exein this folder. - Copy MOV files into this folder.
- Create the script:
C:\temp\ffmpeg\convert.ps1
- Run the script:
cd C:\temp\ffmpeg Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass .\convert.ps1
- Use the WEBM files from the same folder.
