[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.
AlBundy
Bright Spark User
Posts: 377
Joined: Mon Dec 31, 2012 4:47 am

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

Post by AlBundy »

Thanks for the link - using imdb is a good idea but it seems that imdb provides only english data.
Maybe I'll implement a second provider with imdb-data.

Do you have an idea how to include a gem into my scripts?
--> I don't want that the users has to run gem install imdb manually...

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 »

If it were me, I'd package it as a gem. That way to install it they would just run something like 'gem install hbscript' and it would automatically install the dependencies. I work with Ruby every day as my job. If you need any help let me know.
AlBundy
Bright Spark User
Posts: 377
Joined: Mon Dec 31, 2012 4:47 am

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

Post by AlBundy »

I've uploaded a new archive which includes the hb.rb with the new shebang and tag_episode.rb to tag ripped series.
Currently it supports imdb.com and serienjunkies.de

Code: Select all

Usage: tag_episode [options]
        --provider PROVIDER          tag-provider
		sj: get informations from serienjunkies.de (de) - ID = part of the series-url
		imdb: get informations from imdb.com (en) - ID = Name of the series
        --id ID                      series ID (depending on provider)
        --season NUM                 season number
        --episode NUM                episode number
        --name NAME                  series name (overrides name from provider)
        --test                       test-only
        --tag                        tag file
        --rename                     rename file
        --pattern PATTERN            pattern for the new name (default: #name# - #season#x#episode# - #title# (#title_org#).#filename#)
        --help                       Display this screen
see readme.txt for requirements of tag_episode.rb.
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 »

justintime001 wrote: 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!
-Justin
AlBundy wrote:Can you post the used command?

Al

Code: Select all

ruby hb.rb --input "/Volumes/4TB Seagate 2nd/MKV/*.mkv" --output "/Volumes/4TB Seagate 2nd/M4V/#title#.m4v" --preset AppleTV 3 --verbose
To clarify from my initial post, I want my output files to only have the AAC file format, whether that means passing it through or re-encoding the audio track. I don't want any non-AAC tracks. I also want to make sure that each AAC file is converted according to the original audio track. so, AC-3 6-channel --> AAC 6-channel, etc. Thank you Al! I very much look forward to your response.

Justin
Last edited by justintime001 on Tue Aug 13, 2013 7:17 pm, edited 1 time in total.
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 »

You'll probably want to put your preset in quotes as follows:

Code: Select all

--preset "AppleTV 3"
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 »

resinman wrote:You'll probably want to put your preset in quotes as follows:

Code: Select all

--preset "AppleTV 3"
Thanks for the suggestion! I just tried with no difference in results.

When I eventually learn ruby, I'll hopefully be able to fix problems like this myself and share them with everyone.

Until then, any suggestions/ideas?
AlBundy
Bright Spark User
Posts: 377
Joined: Mon Dec 31, 2012 4:47 am

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

Post by AlBundy »

If you use a preset the audio-settings from preset should be taken.
I can check this at end of this week, when I'm back at home.

You can check the generated HandbrakeCLI command line.

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

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

Post by AlBundy »

I've checked the generated command line.
preset-settings are this:

Code: Select all

AppleTV 3:  -e x264  -q 20.0 -r 30 --pfr  -a 1,1 -E faac,copy:ac3 -B 160,160 -6 dpl2,auto -R Auto,Auto -D 0.0,0.0 --audio-copy-mask aac,ac3,dtshd,dts,mp3 --audio-fallback ffac3 -f mp4 -4 -X 1920 -Y 1080 --decomb=fast --loose-anamorphic --modulus 2 -m --x264-preset medium --h264-profile high --h264-level 4.0
generated command line is this (input-file has two audio-tracks):

Code: Select all

"~/Documents/workspace/Handbrake/tools/handbrake/osx/HandBrakeCLI" --input "~/Desktop/testfile.mkv" --output "~/Desktop/temp.m4v" -e x264  -q 20.0 -r 30 --pfr  --audio-copy-mask aac,ac3,dtshd,dts,mp3 --audio-fallback ffac3 -4 -X 1920 -Y 1080 --decomb=fast --loose-anamorphic --modulus 2 -m --x264-preset medium --h264-profile high --h264-level 4.0 --format mp4 --optimize --markers --title 1 --audio 1,1,2,2 --aencoder faac,copy:ac3,faac,copy:ac3 --arate Auto,Auto,Auto,Auto --mixdown dpl2,auto,dpl2,auto --ab 160,160,160,160 --drc 0.0,0.0,0.0,0.0 --aname "Deutsch","Deutsch","English","English" --audio-fallback faac --subtitle 1 2>/dev/null
So in my opinion all looks fine.

Al
meshelton
Posts: 1
Joined: Fri Aug 23, 2013 1:44 pm

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

Post by meshelton »

How would you use this script to try and rip the main track if it's a dvd movie or all the episodes on a dvd tv show?
AlBundy
Bright Spark User
Posts: 377
Joined: Mon Dec 31, 2012 4:47 am

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

Post by AlBundy »

-movie converts the main-track and -episodes converts all tracks in a time-range.

Al
sraptor
Posts: 1
Joined: Fri Sep 06, 2013 3:06 am

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

Post by sraptor »

I tried to follow the step about ruby installing in windows OS. When I do the script I get errors and I dont know why.

This is my error, anybody can help me to this?
Thanks

C:\Ruby200-x64\bin>ruby.exe c:\handbrake\hb.rb --input "e:\prueba\*.mkv" --outpu
t "\prueba2\#title#.m4v" --preset AppleTV 3 --verbose
C:/Ruby200-x64/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require
': cannot load such file -- ./lib/hb_lib.rb (LoadError)
from C:/Ruby200-x64/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:4
5:in `require'
from c:/handbrake/hb.rb:4:in `<main>'
AlBundy
Bright Spark User
Posts: 377
Joined: Mon Dec 31, 2012 4:47 am

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

Post by AlBundy »

Start the script in c:\handbrake.

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

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

Post by AlBundy »

I've uploaded a new version.

The new version builds absolute paths to required libs - so you can run the script from every folder.
reassembler
Posts: 1
Joined: Sat Sep 14, 2013 2:46 am

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

Post by reassembler »

Great work. Really great. Thank you.

How is your work licensed? GPL, Apache, Public Domain, etc.

I can't find a license for your work and I was going to put this up on github for my own convenience (so I can keep track of your changes as well as mine), but I don't want to violate your license and of course won't if you prohibit such a use. Please advise.


Thanks again,

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

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

Post by AlBundy »

I've uploaded a new version with included license (GPLv3) and refactored input- and output-done-commands including some builtin-commands to:
- move
- copy
- delete
- and on osx and linux eject disc

@reassembler: what changes do you want to do an my script?

Al
dyck15
Posts: 1
Joined: Sun Sep 22, 2013 4:27 pm

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

Post by dyck15 »

The script doesn't seem to work with a custom handbrake preset. Any chance of adding that functionality (or was I just doing something wrong)?
AlBundy
Bright Spark User
Posts: 377
Joined: Mon Dec 31, 2012 4:47 am

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

Post by AlBundy »

Do you get an error message?

Just have a look at the printed commandline.

Can you use your preset directly with HandbrakeCLI?
User avatar
Rodeo
HandBrake Team
Posts: 12604
Joined: Tue Mar 03, 2009 8:55 pm

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

Post by Rodeo »

The CLI has built-in presets hardcoded, there is no support for custom presets.
BlueCrypt

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

Post by BlueCrypt »

Rodeo wrote:The CLI has built-in presets hardcoded, there is no support for custom presets.
Well, I thought it was "open source" and anyone could modify its source code to fit their needs if necessary.
User avatar
Rodeo
HandBrake Team
Posts: 12604
Joined: Tue Mar 03, 2009 8:55 pm

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

Post by Rodeo »

BlueCrypt wrote:
Rodeo wrote:The CLI has built-in presets hardcoded, there is no support for custom presets.
Well, I thought it was "open source" and anyone could modify its source code to fit their needs if necessary.
What's that got to do with it?
AlBundy
Bright Spark User
Posts: 377
Joined: Mon Dec 31, 2012 4:47 am

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

Post by AlBundy »

BlueCrypt wrote:
Rodeo wrote:The CLI has built-in presets hardcoded, there is no support for custom presets.
Well, I thought it was "open source" and anyone could modify its source code to fit their needs if necessary.
hb.rb is a script on top of HandbrakeCLI.
Handbrake is open source but I'm not working on the project so feature requests should be posted in the appropriate subforum. ;-)
arman
Posts: 13
Joined: Wed Sep 25, 2013 2:20 pm

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

Post by arman »

Hi,

thank you for your great effort. I am trying to rip a dvd episode but before I reach that step I followed the steps you mentioned in the readme file but I get error messages that I don't understand, could you please give me a hint, what could be the reason for these errors?

I am running this on windows 7. I installed Ruby1.93 in the root of C drive but I get this error and it does not matter if I use flags with my call, I get the same errors. Could you please help me?

C:\handbrake>ruby.exe hb.rb
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- ftools (LoadError)
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from C:/handbrake/lib/commands.rb:1:in `<top (required)>'
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from C:/handbrake/lib/hb_lib.rb:4:in `<top (required)>'
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from hb.rb:4:in `<main>'
AlBundy
Bright Spark User
Posts: 377
Joined: Mon Dec 31, 2012 4:47 am

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

Post by AlBundy »

I've uploaded a new version where I've disabled move, copy and delete commands.
Now you should be able to run the script.

Maybe I can check the real problem on weekend.
arman
Posts: 13
Joined: Wed Sep 25, 2013 2:20 pm

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

Post by arman »

Thank you very much for your fast response.

Now it works but I have one issue. If I want to use other place holder than #pos# I don't get any correct output. I get this character, "/", for #source# and this one, "_", for #title#. If I do the same thing using GUI, Handbrake is able to read {source} and {title} correctly. Am I missing something?
AlBundy
Bright Spark User
Posts: 377
Joined: Mon Dec 31, 2012 4:47 am

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

Post by AlBundy »

Please run your commandline with the additional argument --check and post the output.

Al
Post Reply