Encoding video using Handbrake on x86 NAS
Posted: Sun Jan 31, 2010 11:29 pm
I use HandBrake 0.93 CLI (command line) to encode various video files overnight on my TS-459.
The process should work on any x86 based model.
You will need to get HandBrakeCLI (0.93 version required, not 0.94) installed and on your path before the script will work.
I got it from a Debian package, and manually extracted it (link below).
http://debian-multimedia.org/pool/main/ ... 1_i386.deb
For it to work you create an 'Encode' folder (/share/Public/Encode in the script).
Inside this folder you create a folder for each set of encoding settings.
Each of these folders must contain a file called 'handbrake.profile'. There's an example below.
The script looks for any files with specific extensions, or VIDEO_TS folders within these 'profile' folders (and in any subfolders).
I use cron to run the script at midnight every day.
Here's an example Handbrake profile
The process should work on any x86 based model.
You will need to get HandBrakeCLI (0.93 version required, not 0.94) installed and on your path before the script will work.
I got it from a Debian package, and manually extracted it (link below).
http://debian-multimedia.org/pool/main/ ... 1_i386.deb
For it to work you create an 'Encode' folder (/share/Public/Encode in the script).
Inside this folder you create a folder for each set of encoding settings.
Each of these folders must contain a file called 'handbrake.profile'. There's an example below.
The script looks for any files with specific extensions, or VIDEO_TS folders within these 'profile' folders (and in any subfolders).
I use cron to run the script at midnight every day.
Code: Select all
# !/bin/sh
# encode files in Encode folder with handbrake
ENCDIR=/share/Public/Encode
# profile filename
PROFILE=handbrake.profile
# extension to use when we complete encoding a file
COMPEXT=complete
# flags that we are busy
WORKFILE=$ENCDIR/working
# 1. check work file not present .... quit if it is
if [ -a $WORKFILE ];
then
echo "Encode already in progress ... exiting."
exit 0
fi
echo "Looking for files to encode ..."
touch $WORKFILE
# get list of directories to look in for video files / profiles
PROFDIRS=`find $ENCDIR -type d -name "*"`
for DIR in $PROFDIRS
do
if [ -a "$DIR/$PROFILE" ];
then
OPTIONS=`cat "$DIR/$PROFILE"`
echo "$DIR has profile options : $OPTIONS"
# look for any file with specified extensions
VIDFILES1=`find $DIR -type f -name "*.ts"`
VIDFILES2=`find $DIR -type f -name "*.avi"`
VIDFILES3=`find $DIR -type f -name "*.mkv"`
VIDFILES4=`find $DIR -type f -name "*.m2ts"`
VIDFILES5=`find $DIR -type d -name "VIDEO_TS"`
VIDFILES6=`find $DIR -type f -name "*.mpg"`
VIDFILES7=`find $DIR -type f -name "*.wmv"`
# .. and so on, finally put them all together
VIDFILES="$VIDFILES1 $VIDFILES2 $VIDFILES3 $VIDFILES4 $VIDFILES5 $VIDFILES6 $VIDFILES7"
for VID in $VIDFILES
do
OUTFILE=$VID.mp4
echo "Encoding video file $VID to file $OUTFILE"
# use HandBrakeCLI to encode the file
COMMAND="HandBrakeCLI -i $VID -o $OUTFILE -f mp4 -m -O $OPTIONS"
`$COMMAND`
mv $VID $VID.$COMPEXT
echo "Completed and renamed to $VID.$COMPEXT."
done
fi
done
echo "Completed encoding."
rm $WORKFILE
Code: Select all
-e x264 -b 1200 -2 -T -E faac -B 160 -6 dlp2 --decomb --deblock -w 640