Skip to content

Instantly share code, notes, and snippets.

@jstncno
Created August 14, 2018 16:58
Show Gist options
  • Select an option

  • Save jstncno/35db6e44ba0785de8bea8f08318ec40f to your computer and use it in GitHub Desktop.

Select an option

Save jstncno/35db6e44ba0785de8bea8f08318ec40f to your computer and use it in GitHub Desktop.
Convert a .mov, decoded as AppleProres w/ an alpha channel, to a Chrome-friendly .webm
# Usage: $ mov2webm.sh input.mov output.webm
INPUT=$1
OUTPUT=$2
# Convert a video file (e.g., .mov decoded as AppleProres w/ alpha channel) to a .webm
# ffmpeg -i $INPUT -c:v libvpx-vp9 -pix_fmt yuva420p output.webm
# Convert a video file (e.g., .mov decoded as AppleProres w/ alpha channel) to .png frames
ffmpeg -i $INPUT frame-%02d.png
# Convert .png frames to a .webm
# `yuva420p` pixel format supports alpha channel
ffmpeg -framerate 30 -f image2 -i frame-%02d.png -c:v libvpx-vp9 -pix_fmt yuva420p $OUTPUT
@jstncno
Copy link
Author

jstncno commented Jun 4, 2020

Hi @brendan8c,

Sorry for the super late reply. This requires ffmpeg as a dependency. Make sure to install it before running this script. If you develop on macOS (like I do), you can install ffmpeg using Homebrew.

Once you have ffmpeg installed, you can then run the following command:

$ chmod +x mov2webm.sh
$ ./mov2webm.sh input.mov output.webm

Note: The way this script works is that it first convert the .mov file to a series of .png frames, then use those .png frames to build the .webm video. As a consequence of this, the resulting video will have no audio (having no audio means it can autoplay in Chrome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment