Skip to content

Instantly share code, notes, and snippets.

@hvrauhal
Last active April 17, 2016 17:13
Show Gist options
  • Save hvrauhal/636a63bfb0babb730736 to your computer and use it in GitHub Desktop.
Save hvrauhal/636a63bfb0babb730736 to your computer and use it in GitHub Desktop.
This script uses ffmpeg to convert video to vpx9 and audio to vorbis, then sox to normalize audio, and finally ffmpeg to bundle the streams back together
#!/bin/zsh
# Install needed tools:
# brew install sox --with-libvorbis
# brew install ffmpeg --with-libvpx --with-libvorbis --with-opus --with-faac
set -e
FILENAME=$1
echo "Converting $FILENAME to webm + ogg with normalized audio"
ffmpeg -i ${FILENAME} -c:a libvorbis -vn ${FILENAME}_audio_orig.ogg
ffmpeg -i ${FILENAME} -c:v libvpx-vp9 -crf 50 -b:v 0 -vf scale=840:-1 -g 50 -an ${FILENAME}_video_orig.webm
sox --norm ${FILENAME}_audio_orig.ogg ${FILENAME}_audio_norm.ogg
ffmpeg -i ${FILENAME}_video_orig.webm -i ${FILENAME}_audio_norm.ogg -c copy ${FILENAME}_normalized_full.webm
rm ${FILENAME}_audio_orig.ogg ${FILENAME}_video_orig.webm ${FILENAME}_audio_norm.ogg
# The ISC License
# Copyright (c) 2015, Heikki Rauhala
# Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment