Skip to content

Instantly share code, notes, and snippets.

@davsket
Last active August 29, 2015 14:10
Show Gist options
  • Save davsket/5ea3ba31d08a8fc88ab3 to your computer and use it in GitHub Desktop.
Save davsket/5ea3ba31d08a8fc88ab3 to your computer and use it in GitHub Desktop.
Instructions to generate Ogg and Webm formats for HTML5 videos

Instructions to generate Ogg and Webm formats

These instructions let you generate ogg, webm and mp4 formats playable by all mayor borwsers:

Install homebrew

If you are in a mac, I recommend you to install homebrew:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install ffmpeg

With home brew you can easily install ffmpeg, but its important to install it with the codecs for ogg and webm:

brew install --with-theora --with-libvorbis --with-libx264 --with-x264 --with-libvpx ffmpeg

If you don't have hombrew or mac, you can download and install ffmpeg manually: https://www.ffmpeg.org/download.html

Generate Ogg

ffmpeg -i SourceVideo.mp4 -c:v libtheora -c:a libvorbis -q:v 10 -q:a 10 NewVideo.ogg

Generate Webm

ffmpeg -i SourceVideo.mp4 -c:v libvpx -b:v 1M -c:a libvorbis NewVideo.webm

Generate Mp4

ffmpeg -i SourceVideo.mp4 -c:v libx264 NewVideo.mp4

Extra options

If you want to reduce the size of the video, you can use the flag -s

ffmpeg -i SourceVideo.mp4 -c:v libx264 -s 838x472 NewVideo.mp4

If you want to reduce the quality you can use the flags -b:a and -b:v to change the bit rate of the audio and the video:

ffmpeg -i SourceVideo.mp4 -c:v libx264 -b:a 128k -b:v 1200k NewVideo.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment