Skip to content

Instantly share code, notes, and snippets.

@josecostamartins
Last active January 20, 2016 09:19
Show Gist options
  • Save josecostamartins/9560893 to your computer and use it in GitHub Desktop.
Save josecostamartins/9560893 to your computer and use it in GitHub Desktop.
# This script converts any format to xvid avi currently xvid avi is the only format my DVD player accepts and the newest versions of movies are being launched in x264 mp4
#!/bin/bash
# This script converts any format to xvid avi
# currently xvid avi is the only format my DVD player accepts
# and the newest versions of movies are being launched in x264 mp4
USAGE="$(basename $0) Input [output]"
#filename=$(basename $pathandfile)
#extension=${filename##*.}
#filename=${filename%.*}
# if there are two parameters, file input and file output, create avi xvid with the filename specified in the output
if [ "$#" -eq 2 ]; then
ffmpeg -strict experimental -i "$1" -vcodec libxvid -threads 8 \
-s 624x352 -g 400 -dia_size 514 -bf 1 -b:v 1200k -trellis 2 \
-aspect 1.860 -level 5.1 -r 25 -acodec libmp3lame -ab 128k \
-ac 2 -async 1 -y "$2"
#ffmpeg -strict experimental -i "$1" -threads 3 -s 624x352 -g 400 -dia_size 514 -bf 1 -b 816k -trellis 2 -aspect 1.860 -level 5.1 -r 25 -acodec libmp3lame -ab 128k -ac 2 -async 1 -y "$2"
# if there are only one parameter, file input, use the same name of the input file appending -copy.avi
elif [ "$#" -eq 1 ]; then
filename=$(basename "$1")
extension=${filename##*.}
filename=${filename%.*}
ffmpeg -strict experimental -i "$1" -vcodec libxvid -threads 8 \
-s 624x352 -g 400 -dia_size 514 -bf 1 -b:v 1200k -trellis 2 \
-aspect 1.860 -level 5.1 -r 25 -acodec libmp3lame -ab 128k \
-ac 2 -async 1 -y "$filename-copy.avi"
#ffmpeg -strict experimental -i "$1" -threads 3 -s 624x352 -g 400 -dia_size 514 -bf 1 -b 816k -trellis 2 -aspect 1.860 -level 5.1 -r 25 -acodec libmp3lame -ab 128k -ac 2 -async 1 -y "$filename-copy.avi"
# if there are no parameters, there is an error
else
echo "$USAGE"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment