Created
February 12, 2020 08:59
-
-
Save jameswyse/8d32a4fce5932ffb36b5b15d75a2f314 to your computer and use it in GitHub Desktop.
HTML5 Video Conversion Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# HTML5 Video Conversion Script | |
# Usage: ./html5video.sh file.mp4 640x360 | |
# | |
# Requires FFMPEG 4.2+. To install on OSX: | |
# | |
# brew uninstall ffmpeg | |
# brew cask install xquartz | |
# brew install chromaprint amiaopensource/amiaos/decklinksdk | |
# brew tap homebrew-ffmpeg/ffmpeg | |
# brew uninstall ffmpeg --ignore-dependencies | |
# brew install homebrew-ffmpeg/ffmpeg/ffmpeg $(brew options homebrew-ffmpeg/ffmpeg/ffmpeg | grep -vE '\s' | grep -- '--with-' | grep -vi chromaprint | tr '\n' ' ') | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment