Carbide Red Home

Handbrake DOS Batch Script for FRAPS


This is how to make a batch (.bat) file that will process all your FRAPS videos in a directory and turn them into M4V (aka MP4) video. FRAPS videos while excellent in quality are massive in size. It can be handy to trim them down to a more managable size while still preserving good quality and original dimension.

Make a DOS batch file. Use Notepad (or Notepadd++) to create a basic text file. When you save it, give it a .bat file extension.

I used the following code. You can also download it here encode.bat (File Save As...)

set /A Counter=0
for /f "delims=" %%i IN ('dir /b *.avi *.mpg') do (
    set /A Counter+=1
    echo Transcoding File: %Counter% %%i
    "C:\Program Files\Handbrake\HandBrakeCLI.exe" -i "%%i" -t 1 --angle 1 -c 1
        -o "%%~ni.m4v" -f mp4 -4 --strict-anamorphic --modulus 16 -e x264 -b 16000
        -r 30 --vfr -a 1 -E faac -6 stereo -R Auto -B 160 -D 0 --gain 0 --audio-copy-mask
        none --audio-fallback ffac
echo Finished Transcoding %Counter% files

Running through the batch file...
Counter is used just to keep an eye on how many videos were processed
"For" starts a loop that searches for all files matching the pattern, ending in avi and mpg
The "%%i" is the variable that stores the name of the current file name
The "delims=" lets the For loop match files names with spaces, which FRAPS does
"C:\Program Files\Handbrake\HandBrakeCLI.exe" is the location of your Handbrake installation
Everything else that follows are the options you want.
The best way to get these is to use the normal Handbrake GUI and select everything you want.
Then hit start quickly to intiate the encode and hit stop.
Open up the "Activity Window" as seen in the picture below and copy the parameters in the log

You can safely trim anything after "--audio-fallback ffac" as the marker stuff is unneeded
Replace the source and destination with "%%i" and "%%~ni.m4v". The "~ni" trims the file extension
from %%i, which you then add the m4v extension, or whatever extension you want.


Some advice on options. Use "--strict-anamorphic" to retain the original size of the FRAPS video.
This is a good choice if some of your videos vary. Otherwise if you select 1920 it will make
all videos 1920x???? regardless of original size
"-b 16000" is the bitrate of 16mb/s. This preserves very good quality and file size is reasonable.
It will drop a 4GB FRAPS video down to ~160MB.
"faac -6 stereo -R Auto -B 160" is for setting it to AAC stereo with a bitrate of 160kb/s.
You can go for 256, but 16 should be fine for gaming.

Drop the batch file into the directory with all the videos and double click it.
After its done it should look like this.
CLI Batch

Sample video. 40MB file of World of Warcraft (Cataclysm going live)