help creating a batch file for hbcli.exe

HandBrake for Windows support
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
Post Reply
echohead
Experienced
Posts: 93
Joined: Tue Dec 04, 2007 3:59 am

help creating a batch file for hbcli.exe

Post by echohead »

so i enjoy running programs from the terminal/commandline...but im also lazy. which is the central reason for this question:

i have a _very_ large DVD collection that i am currently in the process of ripping, and then re-encoding with handbrake, so i can have all my movies backed up on my external hard drive. i use the same settings every time:

"movie.iso" (after being ripped) is re-encoded to "movie.avi", using xvid and 128 kb/s 48 khz stereo mp3, target size 695 MB, 2-pass encoding, deblocking, auto-crop.

handbrake is simple to use, but since i am using essentially the same settings for every encode, i was wondering if its possible to create a batch file that calls on hbcli.exe directly, rather than going through handbrake's GUI first. i would like to have it setup so i am just prompted to specify the name of the ISO and the name of the output file, and the batch does the rest.

ive already thought of naming each ISO "movie.iso" or something, and having each output be "movie.avi", and using a much simpler batch that looks something like this:
C:\Program Files (x86)\Handbrake\hbcli.exe -i "C:\MOVIE.ISO" -o "C:\movie.avi" -e xvid -E lame -p -S 695 -2 --deblock -B 128 -R 48 -6 stereo -v
...but i usually have several movie ISO's sitting on the root of my hard drive at any given time, and renaming each ISO and its equivalent avi after each encode is impractical. i feel i should know how to make this, but just cant at the moment. can anyone out there help me out with this?
echohead
Experienced
Posts: 93
Joined: Tue Dec 04, 2007 3:59 am

Post by echohead »

well, ive managed to get this far...

1. copied "cmd.exe" from SysWOW64 folder (would be system32 on 32-bit windows) to the Handbrake folder.

2. created a batch file named "make.bat", which contains the following:
TITLE Handbrake
@ECHO OFF
set input=%1
set output=%2
cd C:\Program Files (x86)\Handbrake
hbcli.exe -i "C:\%input%" -o "C:\Documents and Settings\Root\Desktop\%output%" -e xvid -E lame -p -S 695 -2 --deblock -B 128 -R 48 -6 stereo -v
and put it in the handbrake folder as well.

3. created a shortcut from the cmd.exe i put in the Handbrake folder.




this works well...all i have to do is click the shortcut and type "make movie.iso movie.avi" (different iso and avi names can be used of course), and hbcli.exe goes to work. still, it would be nice to have something a little more user-friendly, that prompts you for the iso and avi names, then uses those variables to execute hbcli.exe.

any help?
evilpenguin
Posts: 21
Joined: Fri Oct 12, 2007 2:44 am

Post by evilpenguin »

Take a look at the 'FOR' command...

Code: Select all

FOR /R %%D in (*.iso) do "hbcli.exe" -i "%%D" -o :%%D.avi" ...
Something like this will search through your directories, and process every file with .iso extention.
daman123x
Novice
Posts: 51
Joined: Mon Dec 10, 2007 2:56 pm

Post by daman123x »

i wrote a little thing in autohotkey - it is LITERALLY a mouse and keyboard script that does the following

launches the gui and manipulates it:
-sets input numerically
-sets output file name AND LOCATION based on input file name
-auto-picks the title with the greatest number of chapters (i didnt know if Auto was set to take chapters, length, or title 1, but i found that #chapters works best for me)
-sets preset and const encode options
-for audio picks the first track. if it is NOT AC3 english, it uses that track and assumes the dvd is foreign - pan's lab, apocalypto, etc and activates subs.
-if not the above condition, picks audio in this preference:
english 5.1, english dolby, english stereo, auto.

output (respective to above):
aac 6ch 320, aac dolby 256, aac stereo, auto

generates the query and adds to queue

this was really the only way i could find to automate this sort of thing without knowing in advance which title or audio track i wanted
Boostaholic
Posts: 8
Joined: Sun Dec 02, 2007 4:24 am

Post by Boostaholic »

I have a php script that does all this on windows, and you can use -L to select the longest title/track

my script is not perfect but it has done automated encoding of over 200 directories so far.
wbyrum
Posts: 33
Joined: Mon Nov 12, 2007 2:01 am

Post by wbyrum »

I don't know if this will be of any help, but here is the typical (or model) text from a batch file that I use for making AppleTV files from decrypted commercial DVDs.

"HandBrakeCLI -i "C:\DVD Temp\A New Wave" -o "G:\DVD Temp\A New Wave.m4v" -e x264 -E faac --crop 0:0:0:0 -p -m -b 2500 -x bframes=0:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=2 -B 160 -R 48 -v && HandBrakeCLI -i "C:\DVD Temp\Abe And Bruno" -o "G:\DVD Temp\Abe And Bruno.m4v" -e x264 -E faac --crop 0:0:0:0 -p -m -b 2500 -x bframes=0:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=2 -B 160 -R 48 -v && HandBrakeCLI -i "C:\DVD Temp\Broken English" -o "G:\DVD Temp\Broken English.m4v" -e x264 -E faac --crop 0:0:0:0 -p -m -b 2500 -x bframes=0:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=2 -B 160 -R 48 -v && HandBrakeCLI -i "C:\DVD Temp\Brooklyn Rules" -o "G:\DVD Temp\Brooklyn Rules.m4v" -e x264 -E faac --crop 0:0:0:0 -p -m -b 2500 -x bframes=0:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=2 -B 160 -R 48 -v && HandBrakeCLI -i "C:\DVD Temp\Delta Farce" -o "G:\DVD Temp\Delta Farce.m4v" -e x264 -E faac --crop 0:0:0:0 -p -m -b 2500 -x bframes=0:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=2 -B 160 -R 48 -v && HandBrakeCLI -i "C:\DVD Temp\Final Contract" -o "G:\DVD Temp\Final Contract.m4v" -e x264 -E faac --crop 0:0:0:0 -p -m -b 2500 -x bframes=0:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=2 -B 160 -R 48 -v && HandBrakeCLI -i "C:\DVD Temp\Georgia Rule" -o "G:\DVD Temp\Georgia Rule.m4v" -e x264 -E faac --crop 0:0:0:0 -p -m -b 2500 -x bframes=0:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=2 -B 160 -R 48 -v && HandBrakeCLI -i "C:\DVD Temp\Live Free Or Die" -o "G:\DVD Temp\Live Free Or Die.m4v" -e x264 -E faac --crop 0:0:0:0 -p -m -b 2500 -x bframes=0:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=2 -B 160 -R 48 -v && HandBrakeCLI -i "C:\DVD Temp\Lonely Hearts" -o "G:\DVD Temp\Lonely Hearts.m4v" -e x264 -E faac --crop 0:0:0:0 -p -m -b 2500 -x bframes=0:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=2 -B 160 -R 48 -v && HandBrakeCLI -i "C:\DVD Temp\Lookout" -o "G:\DVD Temp\Lookouts.m4v" -e x264 -E faac --crop 0:0:0:0 -p -m -b 2500 -x bframes=0:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=2 -B 160 -R 48 -v && HandBrakeCLI -i "C:\DVD Temp\Paper Cut" -o "G:\DVD Temp\Paper Cut.m4v" -e x264 -E faac --crop 0:0:0:0 -p -m -b 2500 -x bframes=0:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=2 -B 160 -R 48 -v && HandBrakeCLI -i "C:\DVD Temp\Played" -o "G:\DVD Temp\Played.m4v" -e x264 -E faac --crop 0:0:0:0 -p -m -b 2500 -x bframes=0:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=2 -B 160 -R 48 -v && HandBrakeCLI -i "C:\DVD Temp\Spiderman 2" -o "G:\DVD Temp\Spiderman 2.m4v" -e x264 -E faac --crop 0:0:0:0 -p -m -b 2500 -x bframes=0:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=2 -B 160 -R 48 -v && HandBrakeCLI -i "C:\DVD Temp\The Hoax" -o "G:\DVD Temp\The Hoax.m4v" -e x264 -E faac --crop 0:0:0:0 -p -m -b 2500 -x bframes=0:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=2 -B 160 -R 48 -v && HandBrakeCLI -i "C:\DVD Temp\Year Of The Dog" -o "G:\DVD Temp\Year Of The Dog.m4v" -e x264 -E faac --crop 0:0:0:0 -p -m -b 2500 -x bframes=0:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=2 -B 160 -R 48 -v"

My movies are stored on an external 500GB hard drive , G:
Hopefully this will help.

Note that the batch file that you create must be run from the directory that contains the HandBrakeCLI.exe file.

Good Luck!
Post Reply