«

»

Sep 20 2012

Using HandBrake to batch convert videos to Roku


fyci5dw1 thumb Using HandBrake to batch convert videos to Roku

It’s been about three months since I picked up my Roku.  From that point, it’s been a roller coaster ride finding all kinds of new stuff to do with it. one of the most exciting things I found that I could do with the Roku [w/Plex] was to be able to play the DVD ISOs that I had in my digital library.  Being able to play the ISOs and not having to convert those files into another format was a huge plus, but I found a few little quirks with playing some ISOs. 

For some reason, some ISOs didn’t work correctly, or what play at all were sometimes I would find that the movie would stop playing for some reason and the Roku doesn’t have a clear resume function to start playing the movie the previous spot. again, I was using my Roku with the Plex channel.  So it’s not so much the Roku, but more of the abilities of the Plex application/channel.

Then I started looking at a lot of the other family videos that I had in my library and then that’s what really hit me that I need to make sure that all these videos are in the same format so that if I want to, I can play these videos through Roku without any problems, or if I decide to switch to another streaming player [ which I may do]   the video format that I go to need to be widely compatible;  speaking mainly to the MP4 format.

I have a decent video library of DVD ISOs, mainly because my son likes to destroy his children’s movies.  I have personally purchased transformers movies at least two or three times, all of them.

If you’ve ever converted videos before, you know that it’s a time-consuming process.  So it makes more sense to place all of your existing videos into one folder and then have an application just dig through that folder and convert everything in it to the format that you want. and it’s also convenient if you can schedule this type of function to happen in the middle of the night while you’re sleeping,  because converting data can also consume a lot of your processing power on your PC, making it really difficult to be productive in just about anything that you’re going to do.

This is when I came to the realization that I needed something to convert my videos in a batch… and I love using HandBrake to convert my videos;  it simply awesome. I haven’t found anything yet that can defeat it.

umb3rmuc thumb Using HandBrake to batch convert videos to Roku

It’s a free application and it has the option to accept command line functions; exactly what you need if you going to be doing batch functions.

But I also needed something that was flexible enough that I could use to build  a list of items to process.  Enter autohotkey. Autohotkey is another application/scripting language that I absolutely love.  It’s very flexible, it has a lot of abilities and it can save you tons of time in doing repetitious functions.

I already had handbrake application to convert videos,  but I needed something to create the process list.

I went digging through the autohotkey support forums and found a script that someone had already been working on.  When I grabbed it, it didn’t do exactly what I wanted to, but the beauty to autohotkey is that you can change the scripts have them do what you want to do;  how you want them to do them.

I’m not taking credit for the script, because I didn’t write it;  I modified it.  All the credit for writing the original script  should go to the author… But here’s the autohotkey script that I use to convert my videos to MP4…

 

;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         A.N.Other <myemail@nowhere.com>
;
; Script Function:
;    Template script (you can customize this template by editing "ShellNewTemplate.ahk" in your Windows folder)
;

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#SingleInstance, Force
#Persistent

ProgName=HandBrakeM
Originalsfolder=C:DVDRipOriginal ISOs
Convertedfolder=Z:ConvertedNot sorted

Traytip, %progname%, Loaded…

FileExt = MP4|ISO|AVI|ASF|WMV ; file extension pattern

SetTimer, Watchmen, 1000 ; check every 5 secs
Return

Watchmen:
If FileExist("*.mp4") || FileExist("*.ISO")|| FileExist("*.avi")|| FileExist("*.ASF")|| FileExist("*.WMV") ; ... for the existense of mpgs and/or avis
    {
    Loop, *.* ; go and get'm
        {
        SplitPath, A_LoopFileLongPath, OutFileName,,, OutNameNoExt ; get file details
        If InStr(FileExt,SubStr(A_LoopFileName,-2)) ; if file extension exists within our pattern
            {
            TrayTip, %progname%, Processing: `n %OutFileName% ...
            RunWait,
                (Join
                 "C:Program Files (x86)HandbrakeHandBrakeCLI.exe"
                 -i "%OutFileName%"
                 -o "%convertedfolder%%OutNameNoExt%.mp4"
                 --preset="Normal"
                ),,
            Filemove, %OutFileName%, %originalsfolder%,1
            TrayTip, %progname%, Moved: `n %OutFileName% ...
            sleep, 3000
            }
        }
    }
else
    {
    msgbox, Nothing was found to process.
    exitapp
    }
Return

 

The autohotkey script,  as it’s presented here,  is to be placed into the directory where the videos are that are supposed to be converted.  I wanted to make sure that once I converted my original files, that I placed those original files into a separate folder so that I knew that they were processed,  and I wanted to place the converted files into a separate folder showing that they were converted.  In my case, I was dropping them directly into my Plex folder.

Understanding that some people may not want to do the same thing that I’m doing, people are welcome to change the originals folder  and the converted folder as needs be, or take the script entirely and convert it to our you want to do it.

With this particular script, you can call out the profile that you want to use with handbrake, using the preset option in the autohotkey script.  If you want to use your custom profile, simply open handbrake, create a new video profile and save it.  come back to the script,  just the preset name and your set.

Again, you can take this autohotkey script,  uses scheduling program and run the batch conversion program in the middle of the night where it’s most convenient,  but when the script doesn’t find anything else in the folder process it exits.

By converting all my videos to MP4, I can enjoy my entire movie collection and if something happens during the playback of the movie, I now have the ability to resume viewing the video; something that I wasn’t able to do with Plex.

I also found that this is really helpful in converting videos to MP4 before uploading them to YouTube.  The conversion method used in handbrake under the normal profile seems generically and overall and all round good balance of size and quality. There’s no need in uploading  100 MB of data when you only have to upload 50 MB of converted data, that’s been optimized.

I hope this helps…

 

Thank you,
Larry Henry Jr.
LEHSYS.com



cancel Using HandBrake to batch convert videos to Roku
umb3rmuc thumb Using HandBrake to batch convert videos to Roku

Using HandBrake to batch convert videos to Roku

Share this with Family and Friends:

social facebook box blue 16 Using HandBrake to batch convert videos to Roku Share
social twitter box blue 16 Using HandBrake to batch convert videos to Roku Tweet
pinterest 16 Using HandBrake to batch convert videos to Roku PinIt
gplus 16 Using HandBrake to batch convert videos to Roku Share
pixel Using HandBrake to batch convert videos to Roku

6 comments

Skip to comment form

  1. phyrun

    Not working, I always get Nothing was found to process.  I’ve ensured that my source and destination folder exists and there’s a video file in the source folder

    1. lehenryjr

      @phyrun I’m still using this script today; it works perfectly for me. I don’t know what to say, but that I don’t know exactly what the problem is, but I literally copied and pasted the script right in to the post.
       
      Later,Larry

  2. JeffreyF

    Larry, I just found your post now and am glad that I did. Like yourself I am in the midst of converting 500+ DVDs to mp4 files for playing on Roku and Plex.

    I have my files in the .iso format and use Handbrake to convert to mp4 using the presets from Ray at http://roku.yt1300.com/index.html

    I have a few questions I am hoping you can help with as I find the process of waiting for Handbrake to load each .iso file and to add that file to the batch a very time consuming process.

    Not quite sure why Handbrake doesn’t batch .iso files like it does with other formats.

    Question I have:

    1. I have a user preset called “DVD Strict Film”. I believe from what you wrote that I can use a preset script. Can you confirm that user preset scripts work as well.

    2. Does the script work with the latest version of Handbrake 0.99?

    3. I have already named my .iso files in the format I would like, does the script preserve the file name as is? If not, how can the script be changed to leave the file name as is?

    4. How would the script be set to run right away or at a certain time (e.g. Run Now or run at XX time)?

    Really excited to hear from you as this could be the answer I have been looking for which would save me quite a bit of time.

    1. Larry Henry Jr.

      Hi Jeffrey,

      Thanks for contacting me…

      1. Any preset scripts that you create for handbrake can be assigned in the AutoHotKey script that’s shown above.

      2. I’m using version 0.9.8 of handbrake and I’m not having any problems with converting my ISOs to MP4. I do this on a regular basis. There really shouldn’t be any change in how the script works such as using the conversion presets that you create or use.

      3. The script shown above does retain the name structure that you provide. The only thing that changes is the extension. Again, I do this on a regular basis.

      4. If you have a directory of ISOs that you need converted, drop the AutoHotKey script into that directory and run the script. If you have a decent machine, converting the movies from ISO to MP4 should take about 20 minutes.

      The conversion script that’s shown above has worked flawless for me. I think the best practice for utilizing the script is scheduling it for off-peak hours of course.

      I hope this helps…

      Later,
      Larry

      1. JeffreyF

        Larry, thanks for the confimations. My next question will clearly show I am not a programmer.

        As you are about to learn, I am anything but a programmer. I am receiving an error message I hope you can help with.

        Here is what I did:

        1. Change the directories to ones on my system

        2. Selected the user preset

        3. Change the directory of HandBrakeCLI.exe to the correct path on my system

        4. Save the script with the .ahk extension and placed this where the .iso files are located

        When I double click on the script I receive:

        The Script file X:Directorypath Script.ahk does nto exist. Create it now.

        When I click on Yes, I receive:

        Could not create the file, perhaps because the current directory is read only or has insufficient permissions.

        The actual script looks is below.

        Any suggestions would be greatly appreciated.

        ;

        ; AutoHotkey Version: 1.x

        ; Language: English

        ; Platform: Win9x/NT

        ; Author: A.N.Other

        ;

        ; Script Function:

        ; Template script (you can customize this template by editing “ShellNewTemplate.ahk” in your Windows folder)

        ;

        #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.

        SendMode Input ; Recommended for new scripts due to its superior speed and reliability.

        SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

        #SingleInstance, Force

        #Persistent

        ProgName=HandBrakeM

        Originalsfolder=X:ISOs To ConvertWaiting to Add To QueueISOConversion

        Convertedfolder=X:ISOs To ConvertWaiting to Add To QueueISO_Originals

        Traytip, %progname%, Loaded…

        FileExt = MP4|ISO|AVI|ASF|WMV ; file extension pattern

        SetTimer, Watchmen, 1000 ; check every 5 secs

        Return

        Watchmen:

        If FileExist(“*.mp4″) || FileExist(“*.ISO”)|| FileExist(“*.avi”)|| FileExist(“*.ASF”)|| FileExist(“*.WMV”) ; … for the existense of mpgs and/or avis

        {

        Loop, *.* ; go and get’m

        {

        SplitPath, A_LoopFileLongPath, OutFileName,,, OutNameNoExt ; get file details

        If InStr(FileExt,SubStr(A_LoopFileName,-2)) ; if file extension exists within our pattern

        {

        TrayTip, %progname%, Processing: `n %OutFileName% …

        RunWait,

        (Join

        “C:Program FilesHandbrakeHandBrakeCLI.exe”

        -i “%OutFileName%”

        -o “%convertedfolder%%OutNameNoExt%.mp4″

        –preset=”DVD Strict Film”

        ),,

        Filemove, %OutFileName%, %originalsfolder%,1

        TrayTip, %progname%, Moved: `n %OutFileName% …

        sleep, 3000

        }

        }

        }

        else

        {

        msgbox, Nothing was found to process.

        exitapp

        }

        Return

        1. Larry Henry Jr.

          If you want, you can send me your script and I will look at it for you, but also if you are using the latest version of AutoHotKey, this could be a problem; as new version ‘L’ and the older versions aren’t fully compatible. If that’s the case try downloading the older version.

          napoleonag.tss@gmail.com

          Later,
          Larry

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>