Skip to content

Instantly share code, notes, and snippets.

@funkenstrahlen
Last active August 29, 2015 13:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save funkenstrahlen/9332026 to your computer and use it in GitHub Desktop.
Save funkenstrahlen/9332026 to your computer and use it in GitHub Desktop.
A small script to convert all AVI files in a folder to mp4/h264
#!/bin/bash
#
# A small script to convert all AVI files in a folder to mp4 h264
# You can either use HandbrakeCLI or ffmpeg.
# ffmpeg requires to be compiled with libx264 which is not default in debian based distributions
#
# To use HandbrakeCLI do not forget to install the packages!
# For Linux Mint I had to do the following to get HandbrakeCLI running:
# sudo add-apt-repository ppa:stebbins/handbrake-snapshots
# sudo apt-get update
# sudo apt-get install handbrake-gtk handbrake-cli
#
# When you use HandbrakeCLI choose a preset from the available presets: 'HandBrakeCLI -z'
#
# Usage:
# ./encode_to_mp4 path/to/directory/that/contains/avi_files/to/convert
#
cd "$1"
mkdir encoded
for f in *.avi
do
echo "processing ${f}"
HandBrakeCLI -Z "High Profile" -i "$f" -o encoded/"${f%.avi}.mp4"
#ffmpeg -i "$f" -r 30 -vcodec libx264 -acodec libfaac -threads 0 -ar 48000 -ab 128k -ac 2 -y -crf 21 -vpre default encoded/"${f%.avi}.mp4"
done
cd -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment