Skip to content

Instantly share code, notes, and snippets.

@elhenro
Created March 13, 2018 13:24
Show Gist options
  • Save elhenro/e6cfecb92b7b9222c461fd682140a90a to your computer and use it in GitHub Desktop.
Save elhenro/e6cfecb92b7b9222c461fd682140a90a to your computer and use it in GitHub Desktop.
convert a video to the web video formats: mp4, webm, ogg
#!/bin/bash
# how to use: sh convertVideoToWebVideoFormats.sh fileToConvert.mp4
# how to use for batch conversion: find "$VIDEOS" -name '*.mp4' -exec sh -c 'ffmpeg ... or sh convertV..
input=$1
output=$(echo $1 | sed 's/^\(.*\)\.[a-zA-Z0-9]*$/\1/')
# mp4
ffmpeg -i $input -vcodec h264 -acodec aac -strict -2 -s 1280x720 $output.mp4
# webm
#ffmpeg -i $input -f webm -vcodec libvpx -acodec libvorbis -ab 128000 -crf 22 -s 1280x720 $output.webm
#ffmpeg -i $input -f webm -s 1280x720 $output.webm
ffmpeg -i $input -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis $output.webm
#ogv
ffmpeg2theora $input -o $output.ogv -x 1280 -y 720 --videoquality 5 --audioquality 0 --frontend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment