• Home
  • Shell
    • Emacs
    • Perl
    • screen
    • sed
  • Ubuntu
    • VNC
  • Web Development
    • Javascript
    • Joomla
    • MySQL
    • osTicket
  • Windows
    • Gimp

Windows> Batch convert video with Handbrake

May13
2011
Written by Scott Rowley

The following code is setup for use with a Nook Color, but you could change the resolution for use with other devices as well. If you have any that you find work well for you please post them in the comments and I will extend the article.

First off, if you don’t already have it you obviously need Handbrake

Thanks to RedShirt for the original code.
handbrake_nook.bat

:: http://www.sudobash.net?p=594
:: Nook Color
@echo off
FOR /F "tokens=*" %%G IN ('DIR "%~1" /B /S /A:-d') do (
FOR /F "tokens=*" %%H IN ('DIR "%%G" /B /A:-d') do (
:: This assumes you have the default install location on Windows 7.
"C:\Program Files (x86)\Handbrake\HandBrakeCLI" -e x264 -2 -b 702 -a 1 -E faac -B 48 -6 mono -R Auto -D 0.0 -f mp4 -I -X 854 -m -x level=30:cabac=0:ref=1:analyse=all:me=umh:no-fast-pskip=1:psy-rd=0,0:bframes=0:weightp=0:subme=6:8x8dct=0:trellis=0 -D 1.5 -i "%%G" -o "C:\Users\YOUR_LOGIN_NAME\Videos\transcode\%%H-NOOK.mp4"
)
)

handbrake_kfire.bat

:: http://www.sudobash.net?p=594
:: Kindle Fire
@echo off
FOR /F "tokens=*" %%G IN ('DIR "%~1" /B /S /A:-d') do (
FOR /F "tokens=*" %%H IN ('DIR "%%G" /B /A:-d') do (
:: This assumes you have the default install location on Windows 7.
"C:\Program Files (x86)\Handbrake\HandBrakeCLI" -e x264 -2 -b 702 -a 1 -E faac -B 48 -6 mono -R Auto -D 0.0 -f mp4 -I -X 1024 -m -x level=30:cabac=0:ref=1:analyse=all:me=umh:no-fast-pskip=1:psy-rd=0,0:bframes=0:weightp=0:subme=6:8x8dct=0:trellis=0 -D 1.5 -i "%%G" -o "C:\Users\YOUR_LOGIN_NAME\Videos\transcode\%%H-FIRE.mp4"
)
)

Make sure the entire command is all on one line with no line breaks or wrapping or this will not work. Don’t forget to change your destination directory to reflect your own login name. Also make sure that the entire destination path exists (by creating the “transcode” directory). Don’t worry about “Videos”, Windows sees that the same as “My Videos”.

Note: This code references the (x86) Program Files. If you are not running 64 bit then this will not be an accurate location:
Untested — Remove ” (x86)” for use on non 64-bit Windows

Now, you can either place the batch file wherever you like and then run it from the command line like so:
handbrake_nook.bat

Or you can run the bat file right from the same directory the video files are in and supply no directory, such as:
handbrake_nook.bat

To Do: Have a nightly check to see if there are any files in the selected directory. If so — convert them and then move the originals to another folder.

Posted in Windows - Tagged bat, batch, color, convert, handbrake, kindle, kindle fire, mobile, nook, transcode, Windows
« Contact Dell via Chat support
» HTPC> Setup Windows 7 as a Media Center with XBMC

10 Comments

  1. Jeff Harbert's Gravatar Jeff Harbert
    January 12, 2012 at 8:32 am

    This was a great help to me. I was looking for Handbrake command line settings for the Nook Color, but the batch functionality is icing on the cake. Thanks for posting this.

    • Scott Rowley's Gravatar Scott Rowley
      January 12, 2012 at 2:13 pm

      Suh-weet! Glad it worked out well for you and thanks for the feedback!

  2. Steven Duckworth's Gravatar Steven Duckworth
    January 12, 2012 at 1:18 pm

    Thanks for the hints. I spent several hours last week tinkering with it and trying to the proper settings to use to export something I edited from Sony Vegas for my Nook Color. Being able to simple export a Youtube-able MP4 and then convert it for Nook in Handbrake will be AWESOME! Thumbs up, my good man!

    • Scott Rowley's Gravatar Scott Rowley
      January 12, 2012 at 2:12 pm

      Awesome! Glad it worked out well for you and thanks for the feedback!

  3. nonob's Gravatar nonob
    June 30, 2012 at 10:14 am

    Hi,

    Thanks for this batch.I modified it and use it to encode my.mov files to .mkv files, fore play on my pc..
    But i have an issue: The new file name keep the old extension of source file name (video.mov.mkv).
    How can i avoid that ? (I want a video.mkv).

    • Scott Rowley's Gravatar Scott Rowley
      June 30, 2012 at 10:22 am

      I’ve been meaning to transcode a couple of movies, this will give me an excuse to and I’ll check it out and get back to you.

      • nonob's Gravatar nonob
        June 30, 2012 at 12:25 pm

        thanks

      • nonob's Gravatar nonob
        July 5, 2012 at 6:33 am

        Hi,

        Something about my request ?

        Thanks

  4. nonob's Gravatar nonob
    July 5, 2012 at 2:05 pm

    I found, it works by adding ~n between the %% and the H :
    “%%~nH”
    Bye

    • Scott Rowley's Gravatar Scott Rowley
      July 5, 2012 at 2:08 pm

      Ah, excellent. Sorry I couldn’t get back to you or conduct my test. Been uber busy. Thanks for posting your solution as well!

Corrections? Questions? Comments?

Find an error?
Everything work out great for you?
Have some feedback?
Like to see something added to the article?

PLEASE leave us a comment after the article and let us know how we are doing, or if something needs corrected, improved or clarified.

Thank you!
- The Management

Advertisement

Sudo Bash
By Geeks - For Geeks

Back to Top