[Script] convert episodes or main-feature from DVD or BD or convert multiple files (on any os)

Discussion of the HandBrake command line interface (CLI)
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.
xr2206
Posts: 7
Joined: Sat Apr 27, 2013 11:07 pm

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

Post by xr2206 » Sat May 04, 2013 1:46 am

AlBundy, I tested the new log and the only first track option and everything works fine.

Communicating directly with the programmer really make thing happened.

Thanks again for your help and patience. Time for me to do batch conversion :D

AlBundy
Bright Spark User
Posts: 370
Joined: Mon Dec 31, 2012 4:47 am

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

Post by AlBundy » Sat May 04, 2013 10:48 am

You're welcome.

Al

AlBundy
Bright Spark User
Posts: 370
Joined: Mon Dec 31, 2012 4:47 am

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

Post by AlBundy » Sun May 05, 2013 5:58 pm

I've uploaded a new version which supports --eject argument (to eject disc after conversion).
Also the required time will be displayed on end of each input.

The --eject argument works only on OSX and Linux.
--> --eject is only displayed in help if command is available.

bsy-web
Posts: 7
Joined: Wed May 08, 2013 5:46 am

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

Post by bsy-web » Thu May 09, 2013 8:55 am

AlBundy,

What is an example of "recursive converting?" I would like to apply your script for distributed rendering on network of computers.

Thanks.

AlBundy
Bright Spark User
Posts: 370
Joined: Mon Dec 31, 2012 4:47 am

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

Post by AlBundy » Thu May 09, 2013 12:25 pm

From help:

Code: Select all

convert all local DVDs recursive in a directory
hb.rb --input "~/DVD/**/VIDEO_TS" --output "~/#title#_#pos#.m4v"
Or

Code: Select all

hb.rb --input "~/DVD/**/*.mkv" --output "~/#title#.m4v"
Al

justintime001
Posts: 5
Joined: Tue May 28, 2013 10:30 pm

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

Post by justintime001 » Tue May 28, 2013 11:00 pm

First of all, I want to thank you for making such an awesome script...THANK YOU! Saved me so much time encoding all file types per directory.

My issue is this: I am converting MKV files (sometimes AVI or FLV), and I am having one issue when using the AppleTV 3 preset you have designated. When using the "--verbose" command, I notice that there are instances in the injected code for each file that essentially requests the file to encode audio tracks into AC3 files (ffac3). Here's an example: "AC3 Passthru requested and input codec is not AC3 for track 2, using AC3 encoder
AC3 Passthru requested and input codec is not AC3 for track 4, using AC3 encoder"

Basically, all of my files have one or more language audio tracks (almost always more than one) and almost all of them (though sometimes none) have subtitles.

My only issue is that when I use the --preset AppleTV 3 command to ensure what I am encoding works with iTunes, I get an extra track for every AAC track that is AC-3. In some instances when the original track was AC-3 6channel I definitely want those original 6-channel AC3 tracks to stay in the M4V file. For anything more than 2 channels, I want it converted to an AC-3 equivalent. However, since I am batch encoding hundreds of files (tv show series and movies), I am forced to open all these files using Subler and individually remove the AC3-2channel tracks, while being careful keep any AC-3 6-Channel tracks.

I realize that the best way for me to state what I am trying to accomplish is this: Convert all audio tracks to AAC (AppleTV3 preset). If the original is AAC 6-channel, then (unless I am mistaken for iTunes and AppleTV compatibility), I want to retain the AAC 6-Channel while having an extra AAC 2-channel track mixdown to work with Apple TV 3. I want the same to be true for any AC-3 6 channel audio tracks. I never want an AC-3 2-channel track since I will always have/need the AAC 2-channel track for iTunes and Apple TV3 compatibility.

The only reason I want to preserve anything more than 2-channel is for the future when it becomes supported in iTunes/AppleTV (3 or 4 etc.)

Any help at all with this would be immensely appreciated! Thank you!

AlBundy
Bright Spark User
Posts: 370
Joined: Mon Dec 31, 2012 4:47 am

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

Post by AlBundy » Wed May 29, 2013 11:24 am

Can you post the used command?

Al

xr2206
Posts: 7
Joined: Sat Apr 27, 2013 11:07 pm

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

Post by xr2206 » Fri May 31, 2013 1:06 am

AlBundy, I just finished to do a part of my ISO Batch conversion to MKV, everything when well, but I still need your help if possible. I got an unforeseen problem that I didn't get when I was testing the script, some of my ISO had corrupted VOB File, that resulted in a uncompleted converted file. I found the problem when doing a quick check of the converted file since no error is reported, so after that I had no choice to check all files to see if the movie credit was present at the end of the movie. This is a tedious operation, there must be a better way.

Do you think it's possible to report an error in the overview section, may be something like this:

z:/Film/Bad_Film.ISO
--> e:/mkv/Bad_Film.mkv [Uncompleted]

I don't know if the script can detect the error when the conversion process stop or if you will have to compare the time length of the source versus the time length of the converted file. If you compare time length, what is best to compare the exact time or a +/- 10 seconds will create less false detect. Hopefully it's feasible.

Thanks again for the script save me a lot of time.

ty2010
Posts: 72
Joined: Mon Feb 18, 2013 7:09 am

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

Post by ty2010 » Fri May 31, 2013 8:39 am

Quick and dirty for windows, add a loop for title numbers if you want. Just drop the batch in a folder of DVDs and let er rip.

Code: Select all

set handbrake="C:\Program Files\Handbrake\HandBrakeCLI.exe"

for /d %%a in (*) do start "encode" /b /low /wait %handbrake% -i "%%a" -t 1 -o "x:\dir\%%a-t1.mp4" -m -f mp4 --detelecine --decomb="fast" --strict-anamorphic -e x264 -q 20 --cfr -a -E faac -B 128 -6 dpl2 -R Auto -D 0 --audio-fallback faac --audio eng --subtitle 1,2,3,4,5,6,7,8,9,10 -x ref=4:weightp=1:rc-lookahead=80:trellis=0:8x8dct=0 --verbose=1

for /d %%a in (*) do start "encode" /b /low /wait %handbrake% -i "%%a" -t 2 -o "x:\dir\%%a-t2.mp4" -m -f mp4 --detelecine --decomb="fast" --strict-anamorphic -e x264 -q 20 --cfr -a -E faac -B 128 -6 dpl2 -R Auto -D 0 --audio-fallback faac --audio eng --subtitle 1,2,3,4,5,6,7,8,9,10 -x ref=4:weightp=1:rc-lookahead=80:trellis=0:8x8dct=0 --verbose=1
Last edited by ty2010 on Sat Jun 01, 2013 6:30 am, edited 1 time in total.

User avatar
Rodeo
HandBrake Team
Posts: 12202
Joined: Tue Mar 03, 2009 8:55 pm

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

Post by Rodeo » Fri May 31, 2013 12:55 pm

Your variable name is just plain wrong.

ty2010
Posts: 72
Joined: Mon Feb 18, 2013 7:09 am

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

Post by ty2010 » Sat Jun 01, 2013 6:26 am

Rodeo wrote:Your variable name is just plain wrong.
It was a less convoluted batch than the ffmpeg one i was using for remuxing, it should be a positive thing like the BMW driver with a Cadillac mug in the cup holder, it's what they *used* to drive. At least it wasn't something I was really frustrated with else there could have been variable names not appropriate for mixed company :/
I once used a variable for handbrake for batch reading of jobs and made an unfortunate condensation for a variable name that made me spit coffee on my keyboard after I typed it.

AlBundy
Bright Spark User
Posts: 370
Joined: Mon Dec 31, 2012 4:47 am

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

Post by AlBundy » Sun Jun 02, 2013 4:09 pm

I've uploaded a new version that
- displays all tracks and subtitles from input before conversion
- filesize, duration, tracks and subtitles of output-file in overview.

Al

[edit]
Upload on mediafire does not work currently - I'll upload the new archive as soon as possible.
[/edit]

AlBundy
Bright Spark User
Posts: 370
Joined: Mon Dec 31, 2012 4:47 am

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

Post by AlBundy » Sun Jun 02, 2013 7:44 pm

New version is uploaded.

hspartel
Posts: 2
Joined: Thu Jun 06, 2013 6:48 pm

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

Post by hspartel » Thu Jun 06, 2013 7:04 pm

Thanks.. script is useful. So far encodings seem to be working well with it and solves a number of problems I was looking at before.

One thing I did have to hack on top of this was a different way to handle foreign language movies. By default I prefer to only include 1 language of audio track (English). However, when I have a movie whose main/first audio track is in a foreign language but also has a dubbed sound track, I prefer to put both in (and subtitles of course). As far as I could tell, it was not possible to do this by default as the script only allows you to specify a static list of languages.

To do this it was necessary to do a little pre-processing on the movies to figure out if there was an alternate language audio track that was probably the original audio. I wrote a little perl jobber which runs handbrake in scan mode and tries to identify the language of the first audio track of the video. The script itself is kind of a nasty hack and you may know a better way to identify the information but it worked for me. I then take the output of this perl script in my shell script wrapper and adjust my command-line options to hb.rb.

Anyway, just figured I would suggest that as a feature to implement within hb.rb itself as it has been useful for me. I've also attached my (very hacked together) perl/script code to show you what I'm doing.

Perl script:

Code: Select all

#!/usr/bin/perl

use strict;
use warnings;

my $main = 0;
my $audio = 0;
open HANDBRAKE, "HandBrakeCLI --scan --main-feature --input . 2>&1 |"
        or die "unable to run HandBrakeCLI: $!\n";
while (<HANDBRAKE>){
        if (/^Found main feature title/){
                $main++;
        }
        if ($main and /^  \+ audio tracks:/){
                $audio++;
        }
        if ($audio and /^    \+ 1, .*? \(iso.*?: (.*?)\)/){
                print "$1\n";
                exit;
        }
}
close HANDBRAKE;
Shell snippet that grabs the returned code:

Code: Select all

LANG=`~/bin/determineNativeLang.pl`
if [[ "$LANG" != "" ]]; then
        LANG="$LANG,eng"
else
        LANG="eng"
fi
As an example, on Crouching Tiger, Hidden Dragon, the perl script identifies the first track as Chinese (outputs: zho). My script then calls hb.rb with --audio zho,eng and I get both audio tracks encoded.

Thanks again for the script.

AlBundy
Bright Spark User
Posts: 370
Joined: Mon Dec 31, 2012 4:47 am

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

Post by AlBundy » Fri Jun 07, 2013 4:44 pm

I'll think about it but what subtitles did you expect?
zho, eng or both?

Al

hspartel
Posts: 2
Joined: Thu Jun 06, 2013 6:48 pm

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

Post by hspartel » Fri Jun 07, 2013 7:21 pm

No worries if not.. my solution works for me.

The use case only makes sense for the audio language I think. Essentially it is giving 2 options: watch with original audio + English subtitles or watch dubbed version [where subtitles aren't neeeded]. So only the native language of subtitles are needed.

Katzen3
Posts: 3
Joined: Tue Apr 23, 2013 6:23 am

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

Post by Katzen3 » Sat Jul 13, 2013 9:36 am

I just finished encoding all of my DVDs with your script and now I'm up for the Blurays. Is there a way to get rid of the decomb? Since Blurays are 1080p theres no need for it but it slows the whole process down. Maybe you could add a --bluray option which will automatically set -4 (because file size will most likely be >4 GB, and if it's not set it will fail at the very last step of creating the file) and unset decomb? (or just a --nodecomb option?)
Or will --xtra "-decomb=0" do the trick?

Thanks a lot.

AlBundy
Bright Spark User
Posts: 370
Joined: Mon Dec 31, 2012 4:47 am

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

Post by AlBundy » Sat Jul 13, 2013 12:46 pm

If handbrake supports --decomb=0 it should work.

But I've uploaded a new version with following new options

Code: Select all

--lang LANGUAGES             set subtitle and audio languges
--bluray                     disables decomb and enables support for mp4-files over 4GB
Al

resinman
Posts: 5
Joined: Tue Jul 30, 2013 2:55 pm

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

Post by resinman » Tue Jul 30, 2013 4:10 pm

Hi All, I just registered for the forum. I have also written a Ruby program to allow me to rip DVD TV series. AlBundy, I believe your script is more comprehensive than mine. However, one thing mine does that may be of interest is that it automatically looks up all of the episode information for the show and names each episode accordingly. I was wondering if you'd be interested in combining our two efforts into a better product? If so please let me know here and I'll pass along the code repository so we can collaborate.

Cheers!

AlBundy
Bright Spark User
Posts: 370
Joined: Mon Dec 31, 2012 4:47 am

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

Post by AlBundy » Tue Jul 30, 2013 6:52 pm

Hi, I also have a separate script to name and tag the converted files. :-)

Because this is currently only working with serienjunkies.de (a german site only for episodes) and needs special gems it's not integrated in hb.rb

If you show me your script, I might get an idea how to integrate both in hb.rb

Al

resinman
Posts: 5
Joined: Tue Jul 30, 2013 2:55 pm

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

Post by resinman » Thu Aug 01, 2013 4:40 pm

Do you have a bitbucket.org account? They are free. I will add you to the repository if you can give me your account username.

AlBundy
Bright Spark User
Posts: 370
Joined: Mon Dec 31, 2012 4:47 am

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

Post by AlBundy » Thu Aug 01, 2013 4:55 pm

I don't have an account - maybe you can upload your script at a free filehoster.

jonnyboy
Posts: 1
Joined: Sat Aug 03, 2013 11:27 pm

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

Post by jonnyboy » Sat Aug 03, 2013 11:33 pm

Just found your script and trying in FreeBSD 9.1. If you change:

Code: Select all

#!/usr/bin/ruby
to

Code: Select all

#!/usr/bin/env ruby
then you should not need to run:

Code: Select all

ruby hb.rb
as it should find ruby in any *nix or *bsd.

Thanks for this script. :)

AlBundy
Bright Spark User
Posts: 370
Joined: Mon Dec 31, 2012 4:47 am

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

Post by AlBundy » Mon Aug 05, 2013 4:15 pm

I've changed the shebang to

Code: Select all

#!/usr/bin/env ruby
- change will be available in next version.

Thanks for the suggestion

Al

resinman
Posts: 5
Joined: Tue Jul 30, 2013 2:55 pm

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

Post by resinman » Mon Aug 12, 2013 2:24 pm

I've got the code here on bitbucket.org. I use the imdb gem to lookup the episodes and automatically name them. Feel free to clone it or get some ideas from it. I'm still working on specs but plan to have 100% test coverage eventually. Any help from Ruby programmers is appreciated.

Post Reply