Page 2 of 14

Re: [Script] rip all episodes or only main-feature from DVD

Posted: Sun Apr 14, 2013 6:36 pm
by AlBundy
some useful commands:
restart
OSX : osascript -e 'tell application "System Events" to restart'
windows: shutdown -r -t 0

sleep
OSX : osascript -e 'tell application "System Events" to sleep'

showdown
OSX : osascript -e 'tell application "System Events" to shut down'
windows: shutdown -s -t 0

logoff
OSX : osascript -e 'tell application "System Events" to log out'
windows: shutdown -l -t 0

eject disc
OSX : drutil tray eject

Re: [Script] rip all episodes or only main-feature from DVD

Posted: Sun Apr 21, 2013 3:23 pm
by ktverdun
I'm running into a little bit of a problem with the recursive script. It seems to run into an infinite loop whenever I run the recursive processing.

My goal is to batch convert a number of dvds that are under a dvd directory. ( --input "./dvd/*/VIDEO_TS" --output "./#title#_#pos#.m4v")
Output with the AppleTV 3 preset, but include all audio tracks and subtitles (--preset "AppleTV 3")
Filter out any small intro files ( --min-length 00:02:00)
Filter out any titles that append all tv episodes into one track but keep double episodes (--max-length 01:45:00)

Here is the full text.

Code: Select all

ruby.exe "c:\handbrake\hb.rb" --input "./dvd/*/VIDEO_TS"  --output "./#title#_#pos#.m4v" --preset "AppleTV 3" --min-length 00:02:00 --max-length 01:45:00
For the sake of a quick test, I added the preview option at the end to validate before spending any length of time processing the batch conversion (--preview 00:00:00-00:00:09)

When it gets to the last file it converts, it continues to detect the same folders over and over again. It doesn't reprocess existing converted titles, but just doesn't seem to end.

Code: Select all

waiting for ./dvd/MOONLIGHT_S1_D1/VIDEO_TS...
processing ./dvd/MOONLIGHT_S1_D1/VIDEO_TS...
waiting for ./dvd/MOONLIGHT_S1_D2/VIDEO_TS...
processing ./dvd/MOONLIGHT_S1_D2/VIDEO_TS...
waiting for ./dvd/MOONLIGHT_S1_D1/VIDEO_TS...
Environment:
ruby 2.0.0p0 (2013-02-24) [x64-mingw32]
Windows 8

Any ideas how to make this end gracefully after it reaches the last conversion folder and title?

Re: [Script] rip all episodes or only main-feature from DVD

Posted: Sun Apr 21, 2013 6:36 pm
by AlBundy
I've uploaded a new file.
Please try again.

Re: [Script] rip all episodes or only main-feature from DVD

Posted: Sun Apr 21, 2013 7:06 pm
by ktverdun
That worked perfectly! It was just a scoping issue for decrementing current_loop?

You have made my day! This script is exactly what I was looking for to batch process a large number of ripped dvds without having to click through the UI!

Re: [Script] rip all episodes or only main-feature from DVD

Posted: Sun Apr 21, 2013 7:22 pm
by AlBundy
Yep - current-loop was decremented for each input.
Now it's decremented after all inputs are processed.

Re: [Script] rip all episodes or only main-feature from DVD

Posted: Tue Apr 23, 2013 6:47 am
by Katzen3
Your script is exactly what native HandbrakeCLI is missing! Only problem I have is encoding multiple mkv's: (I run OS X Mountain Lion with the preinstalled version of ruby.) When I enter '--input "~/Movies/Batch Rip Movies/*.mkv"', it states "processing..." but nothing ever happens. Entering the full path for a file though, everything works alright. Can you help me with this issue?

(Also putting the computer to sleep after finishing gave me an error today, but thats probably something I can figure out by myself.)

Re: [Script] rip all episodes or only main-feature from DVD

Posted: Tue Apr 23, 2013 12:06 pm
by Rodeo
HandBrakeCLI only accepts one input file. Nothing you can do about it, except writing a script or using a pre-made script like here.

Writing a simple script is pretty trivial though:

Code: Select all

for i in *.mkv;
do </path/to/HandBrakeCLI> -i "$i" -o "$i.output.<extension>" 2> "$i.outout.log.txt" <other_options>;
done
…where </path/to/handBrakeCLI> is the full path to HandBrakeCLI (or just HandBrakeCLI is it's in your shell's PATH), <extension> corresponds to the chosen output container (.mp4, .mkv) and <other_options> is the encoding option(s) you want to use. Example:

Code: Select all

for i in *.mkv;
do /usr/local/bin/HandBrakeCLI -i "$i" -o "$i.output.mp4" 2> "$i.outout.log.txt" --preset="AppleTV 3";
done

Re: [Script] rip all episodes or only main-feature from DVD

Posted: Tue Apr 23, 2013 3:51 pm
by AlBundy
But hb.rb supports multiple input-files. :-)
If the mkv are in subdirectories you have to use
--input "~/Movies/Batch Rip Movies/*/*.mkv"

Al

Re: [Script] rip all episodes or only main-feature from DVD

Posted: Tue Apr 23, 2013 5:39 pm
by AlBundy
Katzen3 wrote:...'--input "~/Movies/Batch Rip Movies/*.mkv"', it states "processing..." but nothing ever happens. ...
Do you see "processing ..." or "processing <your_file>..."?

If you only see "processing..." somethings seems wrong.

I've uploaded a new version with slightly modified parameter-handling.
You can try it if you want.

Al

Re: [Script] rip all episodes or only main-feature from DVD

Posted: Tue Apr 23, 2013 6:44 pm
by Katzen3
I just checked, it's "waiting for ~Movies/Batch Rip Movies/*.mkv" not processing. (wrote that from my phone :oops: )

With the new Version, I get "found no files for pattern ~Movies/Batch Rip Movies/*.mkv". Using /Users/MyUsername/Movies/Batch Rip Movies/*.mkv though works just fine, which also wasn't the case before.

Thanks for your help : )

Re: [Script] rip all episodes or only main-feature from DVD

Posted: Tue Apr 23, 2013 7:01 pm
by Rodeo
Use ~/Movies, not ~Movies ;-)

Re: [Script] rip all episodes or only main-feature from DVD

Posted: Sat Apr 27, 2013 3:07 pm
by AlBundy
I've uploaded a new archive.
Now ./hb.rb --input "~/Downloads/*/*.mkv" --output "~/#title#.mkv" --loops -1 --wait-timeout 5 should run forever and convert each mkv until download is done.

Re: [Script] rip all episodes or only main-feature from DVD

Posted: Sat Apr 27, 2013 11:24 pm
by xr2206
I'm using this script to do the conversion of my ISO library to MKV. It's working very well, if possible I would like to have more option implemented, like:

#source# : to have my output filename with the same exact filename as my source filename. Right now I'm using #title# but may be because of different information contain in my ISO file I have sometime truncated file name or an output filename DVD_VIDEO when the input filename contain space between the word.

--log output_log.txt : like this after converting a lot of file I will be able to look if all when well. I already change the CMD.EXE program to retain 9999 line but an output log will be safer.

thanks for the script.

Re: [Script] rip all episodes or only main-feature from DVD

Posted: Sun Apr 28, 2013 11:49 am
by AlBundy
I've added #source# and #source_basename# (see help).
If you want to write a logfile simply use tee to redirect all output.
tee is also available for windows (e.g. http://sourceforge.net/projects/getgnuwin32/files/)

If you don't need the console output you can also call

Code: Select all

./hb.rb ...your_args... 2>&1 1>hb.log

Re: [Script] rip all episodes or only main-feature from DVD

Posted: Sun Apr 28, 2013 12:33 pm
by Rodeo
I don't see why you need to redirect both?

Code: Select all

2> hb.log
…will give you the HandBrake activity log. stdout only has the progress report.

Re: [Script] rip all episodes or only main-feature from DVD

Posted: Sun Apr 28, 2013 12:36 pm
by AlBundy
Because hb.rb writes to stdout...

Re: [Script] rip all episodes or only main-feature from DVD

Posted: Sun Apr 28, 2013 12:49 pm
by Rodeo
Might be nice if it wrote to stderr instead, so that you can redirect it all while having progress on stdout?

HandBrakeCLI probably needs a --no-progress option too, maybe I'll look into it after release…

Re: [Script] rip all episodes or only main-feature from DVD

Posted: Sun Apr 28, 2013 12:55 pm
by AlBundy
hb.rb redirects activity log by default to /dev/null - if you specify--verbose for hb.rb you'll see the activity log.

Re: [Script] rip all episodes or only main-feature from DVD

Posted: Sun Apr 28, 2013 7:58 pm
by xr2206
AlBundy, the #source_basename# did the trick for me.

I will look at what you gave me to create the log. Doing my testing, I found out that the problem I encounter are mostly no conversion or a film preview got converted instead of the feature film. To catch the film preview conversion I just have to sort my MKV per size and look for the small one that's easy. For the missing conversion it's a little bit harder if the only thing I know is that I have 100 ISO and only 97 MKV after conversion per example.

I found out that you give an overview of the conversion at the end of the batch processing, that could be good enough to find the missing conversion.

This is the command line I used for film

Code: Select all

hb.rb --input "e:\iso\*.iso" --output "e:\mkv\#source_basename#.mkv" --main --audio-copy --xtra "--quality 19.0 --strict-anamorphic --x264-profile high --x264-preset medium --x264-tune film"
Thanks again for the modification.

Re: [Script] rip all episodes or only main-feature from DVD

Posted: Mon Apr 29, 2013 8:33 pm
by AlBundy
I've uploaded a new version which supports writing a logfile with hb.rb- and HandbrakeCLI-output (see argument --log)

Re: [Script] rip all episodes or only main-feature from DVD

Posted: Wed May 01, 2013 11:10 pm
by xr2206
Albundy, I tested the last version with the --log and there is a cosmetic error it's seem that the \r is not working. The bug happens independent if I used the --log or not. Here an example out the screen output:

Code: Select all

E:\Handbrake_CLI>hb.rb --input "e:\iso\*.iso" --output "e:\mkv\#source_basename#.mkv" --main --audio-copy --log "e:\iso\log.txt" --x
tra "--quality 19.0 --strict-anamorphic --x264-profile high --x264-preset medium --x264-tune film"
["[2013-05-01, 18:59:04]  WARN -- hb.rb: e:/iso/FILM1.ISO (title=FILM1, title_alt=, serial=15282A59123454, name=FILM1)\n"]["[2013-05-01, 18:59:04]  WARN -- hb.rb: converting title 18 00:02:26 720x480 (blocks: 58850)\n"]["[2013-05-01, 18
:59:04]  WARN -- hb.rb:   audio-tracks\n"]["[2013-05-01, 18:59:04]  WARN -- hb.rb:     - track 1: English (AC3) (5.1 ch)\n"]["[2013-
05-01, 18:59:04]  WARN -- hb.rb: \"E:/Handbrake_CLI/tools/handbrake/windows/HandBrakeCLI\" --input \"e:/iso/FILM1.ISO\" --output \"e
:/mkv/FILM1.mkv\" --encoder x264 --quality 20.0 --decomb --detelecine --crop 0:0:0:0 --loose-anamorphic --format mkv --markers --aud
io 1 --aencoder copy --arate auto --mixdown auto --ab auto --drc 0.0 --aname \"English (AC3) (5.1 ch)\" --audio-fallback lame --titl
e 18 --quality 19.0 --strict-anamorphic --x264-profile high --x264-preset medium --x264-tune film 2>NUL\n"]["\r"]["Encoding: task 1
of 1, 1.10 %"]["\r"]["Encoding: task 1 of 1, 2.12 %"]["\r"]["Encoding: task 1 of 1, 3.15 %"]["\r"]["Encoding: task 1 of 1, 3.83 %"][
"\r"]["Encoding: task 1 of 1, 4.52 %"]["\r"]["Encoding: task 1 of 1, 4.86 %"]["\r"]["Encoding: task 1 of 1, 5.20 %"]["\r"]["Encoding
: task 1 of 1, 5.54 %"]["\r"]["Encoding: task 1 of 1, 5.89 %"]["\r"]["Encoding: task 1 of 1, 6.23 %"]["\r"]["Encoding: task 1 of 1,
6.57 %"]["\r"]["Encoding: task 1 of 1, 6.91 %"]["\r"]["Encoding: task 1 of 1, 7.26 %"]["\r"]["Encoding: task 1 of 1, 7.94 %"]["\r"][
"Encoding: task 1 of 1, 8.28 %"]["\r"]["Encoding: task 1 of 1, 8.62 %"]["\r"]["Encoding: task 1 of 1, 8.97 %"]["\r"]["Encoding: task
 1 of 1, 9.31 %"]["\r"]["Encoding: task 1 of 1, 9.65 %"]["\r"]["Encoding: task 1 of 1, 9.99 %"]["\r"]["Encoding: task 1 of 1, 10.34
% (114.79 fps, avg 115.09 fps, ETA 00h00m34s)"]["\r"]["Encoding: task 1 of 1, 10.68 % (114.79 fps, avg 115.09 fps, ETA 00h00m34s)"][
"\r"]["Encoding: task 1 of 1, 11.02 % (79.11 fps, avg 104.13 fps, ETA 00h00m37s)"]["\r"]["Encoding: task 1 of 1, 11.36 % (79.11 fps,
 avg 104.13 fps, ETA 00h00m37s)"]["\r"]["Encoding: task 1 of 1, 11.36 % (79.11 fps, avg 104.13 fps, ETA 00h00m37s)"]["\r"]["Encoding
: task 1 of 1, 11.70 % (79.11 fps, avg 104.13 fps, ETA 00h00m37s)"]["\r"]["Encoding: task 1 of 1, 12.05 % (79.11 fps, avg 104.13 fps
, ETA 00h00m37s)"]["\r"]["Encoding: task 1 of 1, 12.39 % (79.11 fps, avg 104.13 fps, ETA 00h00m37s)"]["\r"]["Encoding: task 1 of 1,
13.07 % (75.83 fps, avg 97.88 fps, ETA 00h00m39s)"]["\r"]["Encoding: task 1 of 1, 13.07 % (75.83 fps, avg 97.88 fps, ETA 00h00m39s)"
]["\r"]["Encoding: task 1 of 1, 13.42 % (75.83 fps, avg 97.88 fps, ETA 00h00m39s)"]["\r"]["Encoding: task 1 of 1, 13.76 % (75.83 fps
, avg 97.88 fps, ETA 00h00m39s)"]["\r"]CTRL-C detected - exiting hb.rb
Thanks.

Re: [Script] rip all episodes or only main-feature from DVD

Posted: Thu May 02, 2013 4:58 am
by AlBundy
I've uploaded a new version - now it should also work on windows. :-)

Al

Re: [Script] rip all episodes or only main-feature from DVD

Posted: Fri May 03, 2013 12:11 am
by xr2206
This version is working fine, I can see that the log will grow pretty fast, if you don't mind is it possible to add one that will log only the "overview" that the script give at the end of the encoding. Something like --log_overview.

Also, there is a feature that I cannot make it work and I will like to because it's interesting it's --only-first-track-per-language I tried it on a film with two English audio tracks one AC3 5.1 and one Dolby Surround and both track got encoded. To my understanding the script should keep only then English track with "highest" quality something like DTS->AC3[5.1...2.0]-> Dolby Surround-> Mono.

So my command is:

Code: Select all

E:\Handbrake_CLI>hb.rb --input "e:\iso\*.iso" --output "e:\mkv\#source_basename#.mkv" --main --audio-copy --only-first-track-per-lan
guage --xtra "--quality 19.0 --strict-anamorphic --x264-profile high --x264-preset medium --x264-tune film"
and I get this:

Code: Select all

[2013-05-02, 20:01:00]  WARN -- hb.rb: e:/iso/FILM.iso (title=FILM, title_alt=FILM, serial=50A1236C________, name=FILM)
[2013-05-02, 20:01:00]  WARN -- hb.rb: converting title 6 01:33:30 720x480 (blocks: 2626136)
[2013-05-02, 20:01:00]  WARN -- hb.rb:   audio-tracks
[2013-05-02, 20:01:00]  WARN -- hb.rb:     - track 1: English (AC3) (5.1 ch)
[2013-05-02, 20:01:00]  WARN -- hb.rb:     - track 2: English (AC3) (Dolby Surround)
[2013-05-02, 20:01:00]  WARN -- hb.rb:     - track 3: Francais (AC3) (5.1 ch)
[2013-05-02, 20:01:00]  WARN -- hb.rb:   subtitles
[2013-05-02, 20:01:00]  WARN -- hb.rb:     - track 1: English
[2013-05-02, 20:01:00]  WARN -- hb.rb:     - track 2: English (Closed Caption)
[2013-05-02, 20:01:00]  WARN -- hb.rb:     - track 3: Francais
[2013-05-02, 20:01:00]  WARN -- hb.rb:     - track 4: Espanol
[2013-05-02, 20:01:00]  WARN -- hb.rb:     - track 5: Closed Captions
[2013-05-02, 20:01:00]  WARN -- hb.rb: "E:/Handbrake_CLI/tools/handbrake/windows/HandBrakeCLI" --input "e:/iso/FILM.iso" --output "
e:/mkv/FILM.mkv" --encoder x264 --quality 20.0 --decomb --detelecine --crop 0:0:0:0 --loose-anamorphic --format mkv --markers --aud
io 1,2,3 --aencoder copy,copy,copy --arate auto,auto,auto --mixdown auto,auto,auto --ab auto,auto,auto --drc 0.0,0.0,0.0 --aname "En
glish (AC3) (5.1 ch)","English (AC3) (Dolby Surround)","Francais (AC3) (5.1 ch)" --audio-fallback lame --subtitle 1,2,3,4,5 --title
6 --quality 19.0 --strict-anamorphic --x264-profile high --x264-preset medium --x264-tune film 2>NUL
Encoding: task 1 of 1, 0.26 %CTRL-C detected - exiting hb.rb
Like you see both English track got encoded. Thanks for your help.

Re: [Script] rip all episodes or only main-feature from DVD

Posted: Fri May 03, 2013 12:44 am
by xr2206
AlBundy, I forgot to tell you that the Dolby Surround track was not a commentary track (that will be exclude of the process), here is the --check information

Code: Select all

 audio-tracks:
 subtitles:
   1. Unknown (lang=und, comment=, commentary=false)
 chapters:
   1. 00:00:11 (cells=0->1, blocks=65)
itle 06: 01:33:30, 720x480, 23.976 fps, main-feature: true, blocks: 2626136, chapters: 38, audio-tracks: eng,eng,fra, subtitles: en
,eng,fra,spa,eng
 audio-tracks:
   1. English (AC3) (5.1 ch) (codec=AC3, channels=5.1 ch, lang=eng, comment=, rate=48000Hz, bitrate=384000bps, commentary=false)
   2. English (AC3) (Dolby Surround) (codec=AC3, channels=Dolby Surround, lang=eng, comment=, rate=48000Hz, bitrate=192000bps, comm
ntary=false)
   3. Francais (AC3) (5.1 ch) (codec=AC3, channels=5.1 ch, lang=fra, comment=, rate=48000Hz, bitrate=384000bps, commentary=false)
 subtitles:
   1. English (lang=eng, comment=, commentary=false)
   2. English (Closed Caption) (lang=eng, comment=Closed Caption, commentary=false)
   3. Francais (lang=fra, comment=, commentary=false)
   4. Espanol (lang=spa, comment=, commentary=false)
   5. Closed Captions (lang=eng, comment=, commentary=false)

Re: [Script] rip all episodes or only main-feature from DVD

Posted: Fri May 03, 2013 6:49 pm
by AlBundy
--only-first-per-language takes just the first audio-track per language and skips following (quality doesn't matter).
--> This works good in most cases.
Until now the parameter worked only if you specify a language with --audio.
--> I've uploaded a new archive where the parameter works if no language was set.

I've also added two new log-options (--log-override and --log-overview).

Hope this helps.

Al