Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@liamcurry
Forked from markupboy/html5video.sh
Created May 14, 2012 20:24
Show Gist options
  • Star 30 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save liamcurry/2696512 to your computer and use it in GitHub Desktop.
Save liamcurry/2696512 to your computer and use it in GitHub Desktop.
automated conversion of a file to all three html5 compatible video formats - h.264, ogg, and webm
#!/bin/sh
# Output file for HTML5 video
# requirements: ffmpeg .6+
# usage: ./html5video.sh infile.mp4 640x360
target_directory='converted'
file=`basename $1`
filename=${file%.*}
filepath=`dirname $1`
destination="$filepath/$target_directory"
if ! test -d "$destination"
then
mkdir $destination
fi
# Ogg/Theora
ffmpeg -i $1 \
-acodec libvorbis -ac 2 -ab 96k -ar 44100 \
-b:v 345k -s $2 $destination/$filename.ogv
# WebM/vp8
ffmpeg -i $1 \
-acodec libvorbis -ac 2 -ab 96k -ar 44100 \
-b:v 345k -s $2 $destination/$filename.webm
# MP4/h264
ffmpeg -i $1 \
-acodec libfaac -ab 96k \
-vcodec libx264 \
-level 21 -refs 2 -b:v 345k -bt 345k \
-threads 0 -s $2 $destination/$filename.mp4
@mhulse
Copy link

mhulse commented Jun 16, 2016

If using homebrew:

brew install ffmpeg --with-libvpx --with-theora --with-libogg --with-libvorbis

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