5

Here is what I'd like to do in Windows 7:

  1. Monitor a folder for new ISO files (Blu-ray ISOs).
  2. When there is a new file detected, launch Handbrake in the background and encode the ISO to MKV based on a specific profile of saving quality/filename/location (does this require mounting the ISO?)
  3. If Handbrake is already doing an operation, add the new ISO detected to a Handbrake queue of some kind.

I am at a loss as to where to begin. Some questions:

  • Should I get some file monitoring software that launches a VBScript that does the work?
  • Can Handbrake be launched in the background or via console to do what I want it to do?
  • Is there a way to add to the queue for Handbrake, or at least detect when a job has been finished?
  • If I have to mount each ISO, how can I do this automated as well?

Looking for ideas on how to accomplish this.

3
  • I recall there being a Handbrake automating script that would watch for files added to folders. No idea how it's called though.
    – slhck
    Dec 8, 2012 at 21:23
  • I don't think MS-windows has asynchronous file watches, but you could write a script to poll the files, then you have to call your tool HandBrake to tell it what happened. Are you still trying to do this? Nov 19, 2013 at 22:33
  • Windows 7/8 can indeed async monitor a folder without an infinite loop or timer. I can't help with the handbrake command as I don't use the program, but I can assist with the monitoring of folders/files. Please check out my answer on this SU question. And see if it helps you at all.
    – Joseph
    Mar 20, 2015 at 22:15

1 Answer 1

2

I used to do something like what your looking for. This is a very basic loop that searches for all files with a .iso extension. It then encodes them into Xbox 360 preset with a .mp4 extension. Save that file as .bat and you can run it to encode your files.

@echo off
for %%f in (*.iso) do (
    M:\HandBrakeCLI -i 'M:\encode\%%f' -o 'M:\encode\%%f.mp4' -Z 'Xbox 360' -S '700' -2 -T -L
)
pause

Be aware that the above script will encode every file in the M:\encode\ folder, so you'll want to add a little more code. One option would be to move the files out of that directory once they are encoded, another option would be to check if the file has been encoded already or not.

Once you have the script how you want it, you can set Windows Scheduler to run the script at a set interval. I run mine every night at midnight, but if you want faster results you could have it run every 10 minutes (just make sure it doesn't start encoding a movie a second time if it takes longer than 10 minutes to encode).

I have since switched to Linux and my Linux script uses a little bit more logic that you might find useful. This script checks if the file has already been encoded (if it exists), and if it has, it skips it. I'm afraid I'm not good enough at Batch to write this logic without some research, but I know it's possible.

#### Checks if .mov file exists and encodes it if it does not exist ####
for file in *.ISO
do
    if [ -f /raid/mp4/${file%.*}.mov ] || [ -f /raid/mp4/${file%.*}.ISO.mov ]
    then
        echo "Already Encoded ${file}"
    else
        echo /media/raid/mp4/"${file%.*}.mov"
        HandBrakeCLI -i "${file}" --main-feature -o /media/raid/mp4/"${file%.*}.mov" -f mp4 -O --strict-anamorphic -e x264 -q 20 -a 1 -E faac -6 dpl2 -R Auto -B 160 -D 0.0 --markers="${file}-chapters.csv" -x ref=2:bframes=2:subq=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0 --verbose=1
    fi
done

To Answer your Questions:

  1. I would recommend just running the script on a schedule as opposed to adding software.
  2. Either will work, background is probably most convenient.
  3. I think their is a way to queue up files, I just run it serially, i.e. one at a time until it's done,
  4. No, Handbrake does not require the files to be mounted.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .