Skip to content

Instantly share code, notes, and snippets.

@julesjans
Last active October 12, 2016 21:24
Show Gist options
  • Save julesjans/d7b89ed1c5a8ec0be149288d2eefa891 to your computer and use it in GitHub Desktop.
Save julesjans/d7b89ed1c5a8ec0be149288d2eefa891 to your computer and use it in GitHub Desktop.
Converts video (mp4/m4v) into web mp4 & ogv, requires ffmpeg & exiftool
#!/bin/sh
# VIDEO Conversion Tool
# Takes a source directory, and converts for the web into an output directory
# Arguments: src, dest
# Set the title of the source file
# for f in "${1%/}"/*.{mp4,m4v}
# do
# filename=$(basename "$f")
# echo "Preparing $filename:"
# exiftool -title="${filename%.*}" -overwrite_original "$f"
# echo "Completed $filename."
# done
# Perform the conversions
for f in "${1%/}"/*.{mp4,m4v}
do
if [ -f "$f" ]
then
filename=$(basename "$f")
echo "Preparing $filename:"
# ffmpeg -i "$f" "${2%/}/${filename%.*}_original".mp4
# exiftool -title="${filename%.*}" -overwrite_original "${2%/}/${filename%.*}_original".mp4
ffmpeg -i "$f" -b:v 1200k -b:a 128k "${2%/}/${filename%.*}".mp4
ffmpeg -i "$f" -c:v libtheora -b:v 1200k -c:a libvorbis -b:a 128k "${2%/}/${filename%.*}".ogv
exiftool -title="${filename%.*}" -overwrite_original "${2%/}/${filename%.*}".mp4
exiftool -title="${filename%.*}" -overwrite_original "${2%/}/${filename%.*}".ogv
echo "Completed $filename."
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment