get-them-all-no-matter-what setting for subtitles?

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.
User avatar
Rodeo
HandBrake Team
Posts: 12626
Joined: Tue Mar 03, 2009 8:55 pm

Re: get-them-all-no-matter-what setting for subtitles?

Post by Rodeo »

For your use case, it might make sense to script MakeMKV to rip to Matroska files first, discard files that you don't want, then re-encode what's left with HandBrake.

For questions regarding MakeMKV's command-line interface, go to https://www.makemkv.com/forum/
markfilipak
Bright Spark User
Posts: 237
Joined: Thu Aug 01, 2019 8:58 pm

Re: get-them-all-no-matter-what setting for subtitles?

Post by markfilipak »

Rodeo wrote: Sat May 02, 2020 7:33 pmStar Wars, Terminator 2, the Alien collection on Blu-ray come to mind off the top of my head, but there's literally dozens if not hundreds of releases with multiple files per title.
Oh, dear. You're right. I forgot about branching. Another good example is three versions of "Blade Runner" on one disc.

Maybe I process those without a script.
markfilipak
Bright Spark User
Posts: 237
Joined: Thu Aug 01, 2019 8:58 pm

Re: get-them-all-no-matter-what setting for subtitles?

Post by markfilipak »

Rodeo wrote: Sat May 02, 2020 7:36 pm For your use case, it might make sense to script MakeMKV to rip to Matroska files first, discard files that you don't want, then re-encode what's left with HandBrake.

For questions regarding MakeMKV's command-line interface, go to https://www.makemkv.com/forum/
Thanks for that. I've been using AnyDVD-HD & mkvmerge to rip to MKVs. AnyDVD-HD is totally transparent and mkvmerge does what I want, but I'll give makemkv a look. Perhaps it will handle the subs & chaps better.
User avatar
Rodeo
HandBrake Team
Posts: 12626
Joined: Tue Mar 03, 2009 8:55 pm

Re: get-them-all-no-matter-what setting for subtitles?

Post by Rodeo »

if you have a working setup with AnyDVD and mkvmerge, then why do you need HandBrake to read the BDMV source to begin with? Just use mkvmerge's output as HandBrake's input.
markfilipak
Bright Spark User
Posts: 237
Joined: Thu Aug 01, 2019 8:58 pm

Re: get-them-all-no-matter-what setting for subtitles?

Post by markfilipak »

By the way, have I recently said how much I love HB-GUI and good it is to be back here? If only HB could remux without transcoding... Or, if only HB could 55-telecine...
markfilipak
Bright Spark User
Posts: 237
Joined: Thu Aug 01, 2019 8:58 pm

Re: get-them-all-no-matter-what setting for subtitles?

Post by markfilipak »

Rodeo wrote: Sat May 02, 2020 7:45 pm if you have a working setup with AnyDVD and mkvmerge, then why do you need HandBrake to read the BDMV source to begin with? Just use mkvmerge's output as HandBrake's input.
I use HB to get the subs & chaps.

Step 1: Use mkvmerge to fix any time stamp problems that cause ffmpeg to puke.
Step 2: Send mkvmerge's output MKV to ffmpeg for 55-telecining but without subs -- they make ffmpeg screw up the PTSs.
Step 3: Use HB to process the source just to get the subs & chaps (which mkvmerge doesn't get) into a 2nd MKV.
Step 4: Merge MKV #1 & MKV #2 via mkvmerge.

PS: I discovered this morning that I can do Step 4 with ffmpeg.
markfilipak
Bright Spark User
Posts: 237
Joined: Thu Aug 01, 2019 8:58 pm

Re: get-them-all-no-matter-what setting for subtitles?

Post by markfilipak »

You know. all this rigamarole would be unneeded if either, 1, HB could remux, or 2, HB did 55-telecine.
markfilipak
Bright Spark User
Posts: 237
Joined: Thu Aug 01, 2019 8:58 pm

Re: get-them-all-no-matter-what setting for subtitles?

Post by markfilipak »

I'd much rather do everything in HB (and besides that, I like the folks here).
markfilipak
Bright Spark User
Posts: 237
Joined: Thu Aug 01, 2019 8:58 pm

Re: get-them-all-no-matter-what setting for subtitles?

Post by markfilipak »

By the way, in case you're wondering why I just don't feed 24FPS to the TV:

The TV is 60Hz. Does it use 46 pull-down (which would result in 6Hz judder but no combing)? No. It does 23 pull-down + freq doubling (which produces 6Hz judder AND combing). Even though it somewhat smooths the combing, the result is awful.

I would buy a 120Hz TV if I could. But I seek a solution for everyone who has a 60Hz TV.

PS: If I turn motion compensation ON in the TV, the video is worse than awful.
rollin_eng
Veteran User
Posts: 3611
Joined: Wed May 04, 2011 11:06 pm

Re: get-them-all-no-matter-what setting for subtitles?

Post by rollin_eng »

Can you not create a mkv from mkvmerge with just the subtitles and chapters in?
markfilipak
Bright Spark User
Posts: 237
Joined: Thu Aug 01, 2019 8:58 pm

Re: get-them-all-no-matter-what setting for subtitles?

Post by markfilipak »

rollin_eng wrote: Sat May 02, 2020 8:25 pm Can you not create a mkv from mkvmerge with just the subtitles and chapters in?
Nope.
rollin_eng
Veteran User
Posts: 3611
Joined: Wed May 04, 2011 11:06 pm

Re: get-them-all-no-matter-what setting for subtitles?

Post by rollin_eng »

Or create a second mkv with audio/video/subs/chapters then drop whatever you don’t want when you merge.
markfilipak
Bright Spark User
Posts: 237
Joined: Thu Aug 01, 2019 8:58 pm

Re: get-them-all-no-matter-what setting for subtitles?

Post by markfilipak »

rollin_eng wrote: Sat May 02, 2020 8:33 pm Or create a second mkv with audio/video/subs/chapters then drop whatever you don’t want when you merge.
You're trying to optimize to save me time. That's nice. A 2nd MKV is what I make with HB, but only for subs & chaps and only from the original video, not an MKV.

Step 1 has to be done with mkvmerge because I can't do it with HB because HB transcodes. Also, I can't include subs in this MKV.
Step 2 has to be done with ffmpeg because I can't do it with HB because HB can't do 55-telecine. I feed the MKV to ffmpeg.
Step 3 has to be done with HB because HB is the only thing I have that will get subs & chaps. However, HBCLI doesn't get the chaps. Since HB must transcode (which I then throw away) I have a preset that encodes MPEG2 at the lowest quality possible (so at least it goes faster).
Step 4 is where I merge the 2 MKVs.

PS: I suppose when I form a proper HBCLI command line with proper preset directives I'll get the subs & chaps. But today ii's not raining so today I mow the grass for the 1st time this year. I'll get around to fixing my HBCLI command line tomorrow.

PPS: I live in Ohio. A day in springtime without rain is rare.
markfilipak
Bright Spark User
Posts: 237
Joined: Thu Aug 01, 2019 8:58 pm

Re: get-them-all-no-matter-what setting for subtitles?

Post by markfilipak »

This command line:
HandBrakeCLI --preset-import-gui --preset="p24-subs-&-chaps" --input D:\BDMV\STREAM\00001.m2ts --output "C:\AVOut\00001.01.3-handbrake.MKV"
worked wonderfully. All the subs & chaps are there and identified...
However, it needs to be in 'handbrakecli --help' in full: "Useful commands".

This command line:
HandBrakeCLI --title 0 --input D:
worked wonderfully...
However,
1, It needs to be in 'handbrakecli --help' in full: "Useful commands", and
2, It is too verbose, and
3, It's format doesn't lend itself to filtering or parsing in a Windows script.
May I make a suggestion?
"[22:21:40] bd: scanning title 1
"[22:21:40] bd: duration is 02:51:57 (10317307 ms)
"...etc..."
needs to also be in a single line, something like
"title 1: 16:9, 02:51:57, 6 audios, 6 subtitles, 38 chapters"
so it can be found by filtering for "title" and shown, with all others, to the user for quick & efficient identification.
User avatar
Rodeo
HandBrake Team
Posts: 12626
Joined: Tue Mar 03, 2009 8:55 pm

Re: get-them-all-no-matter-what setting for subtitles?

Post by Rodeo »

The parseable input is at the end, e.g.

Code: Select all

[11:41:19] libhb: scan thread found 1 valid title(s)
 + title 1:
  + playlist: 00000.MPLS
  + duration: 00:09:56
  + size: 1920x1080, pixel aspect: 1/1, display aspect: 1.78, 24.000 fps
  + autocrop: 0/0/0/0
  + chapters:
    + 1: duration 00:09:56
    + 2: duration 00:00:00
  + audio tracks:
    + 1, English (DTS) (5.1 ch) (1536 kbps) (iso639-2: eng), 48000Hz, 1536000bps
    + 2, English (DTS-HD MA) (5.1 ch) (iso639-2: eng)
  + subtitle tracks:

HandBrake has exited.
markfilipak
Bright Spark User
Posts: 237
Joined: Thu Aug 01, 2019 8:58 pm

Re: get-them-all-no-matter-what setting for subtitles?

Post by markfilipak »

Rodeo wrote: Sun May 03, 2020 9:42 am The parseable input is at the end, e.g.
Thanks for taking the time to replicate that, Rodeo, but it doesn't work in Windows for 2 reasons:
1, The HBCLI console output will not pipe to FINDSTR (see Note 1), and
2, Even if [1] was not an issue, each "+ title" needs to be a single line, not multiple lines (see Note 2).

Note 1: I think the problem is that HBCLI's console output is using stderr. I think Windows can pipe only stdout.
Note 2: The Windows FINDSTR function can use what Microsoft calls "regular expressions" but they are not 'normal' RegExp and are insanely difficult to craft.

In short, what's needed is something like this:

Code: Select all

+ title 1: 02:51:57, 1920x1080, 38 chapters, 6 audio tracks, 6 subtitle tracks
+ title 3: 00:04:54, 720x480, 2 chapters, 1 audio tracks, 0 subtitle tracks
+ title 5: 00:02:31, 1920x1080, 2 chapters, 1 audio tracks, 0 subtitle tracks
Not this:

Code: Select all

+ title 1:
  + Main Feature
  + playlist: 00001.MPLS
  + duration: 02:51:57
  + size: 1920x1080, pixel aspect: 1/1, display aspect: 1.78, 23.976 fps
  + autocrop: 102/102/0/0
  + chapters:
    + 1: duration 00:06:20
    + 2: duration 00:02:02
    + 3: duration 00:03:44
    + 4: duration 00:02:56
    + 5: duration 00:08:58
    + 6: duration 00:03:28
    + 7: duration 00:02:58
    + 8: duration 00:02:04
    + 9: duration 00:04:22
    + 10: duration 00:02:38
    + 11: duration 00:14:28
    + 12: duration 00:02:37
    + 13: duration 00:03:59
    + 14: duration 00:04:39
    + 15: duration 00:02:51
    + 16: duration 00:06:03
    + 17: duration 00:04:23
    + 18: duration 00:05:09
    + 19: duration 00:04:19
    + 20: duration 00:03:24
    + 21: duration 00:09:25
    + 22: duration 00:02:28
    + 23: duration 00:05:07
    + 24: duration 00:08:09
    + 25: duration 00:03:57
    + 26: duration 00:05:36
    + 27: duration 00:02:48
    + 28: duration 00:04:07
    + 29: duration 00:06:17
    + 30: duration 00:06:27
    + 31: duration 00:04:35
    + 32: duration 00:05:20
    + 33: duration 00:01:33
    + 34: duration 00:03:38
    + 35: duration 00:05:07
    + 36: duration 00:04:48
    + 37: duration 00:01:15
    + 38: duration 00:00:01
  + audio tracks:
    + 1, English (DTS) (5.1 ch) (1536 kbps) (iso639-2: eng), 48000Hz, 1536000bps
    + 2, English (DTS-HD MA) (5.1 ch) (iso639-2: eng)
    + 3, English (AC3) (5.0 ch) (448 kbps) (iso639-2: eng), 48000Hz, 448000bps
    + 4, español (AC3) (2.0 ch) (224 kbps) (iso639-2: spa), 48000Hz, 224000bps
    + 5, Francais (AC3) (2.0 ch) (224 kbps) (iso639-2: fra), 48000Hz, 224000bps
    + 6, English (AC3) (2.0 ch) (224 kbps) (iso639-2: eng), 48000Hz, 224000bps
  + subtitle tracks:
    + 1, English [PGS]
    + 2, 中文 [PGS]
    + 3, 中文 [PGS]
    + 4, English [PGS]
    + 5, español [PGS]
    + 6, Francais [PGS]
+ title 3:
  + playlist: 00003.MPLS
  + duration: 00:04:54
  + size: 720x480, pixel aspect: 10/11, display aspect: 1.36, 29.970 fps
  + autocrop: 64/62/0/14
  + chapters:
    + 1: duration 00:04:54
    + 2: duration 00:00:01
  + audio tracks:
    + 1, English (AC3) (2.0 ch) (224 kbps) (iso639-2: eng), 48000Hz, 224000bps
  + subtitle tracks:
+ title 5:
  + playlist: 00006.MPLS
  + duration: 00:02:31
  + size: 1920x1080, pixel aspect: 1/1, display aspect: 1.78, 23.976 fps
  + autocrop: 130/132/0/2
  + chapters:
    + 1: duration 00:02:30
    + 2: duration 00:00:01
  + audio tracks:
    + 1, English (AC3) (5.1 ch) (448 kbps) (iso639-2: eng), 48000Hz, 448000bps
  + subtitle tracks:
markfilipak
Bright Spark User
Posts: 237
Joined: Thu Aug 01, 2019 8:58 pm

Re: get-them-all-no-matter-what setting for subtitles?

Post by markfilipak »

For example, the best I've been able to do is

Code: Select all

I:\>HandBrakeCLI --title 0 --input I: 2> c:\avout\foo.txt & type c:\avout\foo.txt | FINDSTR /L "+" | FINDSTR /L "title"

+ title 1:
  + subtitle tracks:
+ title 3:
  + subtitle tracks:
+ title 5:
  + subtitle tracks:
rollin_eng
Veteran User
Posts: 3611
Joined: Wed May 04, 2011 11:06 pm

Re: get-them-all-no-matter-what setting for subtitles?

Post by rollin_eng »

Try eac3to if you want to just extract subs and chapters.
markfilipak
Bright Spark User
Posts: 237
Joined: Thu Aug 01, 2019 8:58 pm

Re: get-them-all-no-matter-what setting for subtitles?

Post by markfilipak »

rollin_eng wrote: Sun May 03, 2020 3:48 pm Try eac3to if you want to just extract subs and chapters.
I searched 'handbrakecli --help' for "eac3to" and found no joy. What is "eac3to"?
rollin_eng
Veteran User
Posts: 3611
Joined: Wed May 04, 2011 11:06 pm

Re: get-them-all-no-matter-what setting for subtitles?

Post by rollin_eng »

https://forum.doom9.org/showthread.php?t=125966

edit: you should also look up Ripbot264, it might be more suited to what you are trying to achieve.
markfilipak
Bright Spark User
Posts: 237
Joined: Thu Aug 01, 2019 8:58 pm

Re: get-them-all-no-matter-what setting for subtitles?

Post by markfilipak »

rollin_eng wrote: Sun May 03, 2020 3:55 pm https://forum.doom9.org/showthread.php?t=125966

edit: you should also look up Ripbot264, it might be more suited to what you are trying to achieve.
Hi rollin_eng,

I installed and tried 'eac3to'. I also read about 'Ripbot264'. Sorry, but I don't see how they help.

Though it would be very helpful if there was a way to pursuade 'handbrakecli' to not spend time doing a video transcode (that then I throw away), that's a very minor issue because my scripts will be run overnight and speed is not terribly important.

My focus is transcoding 'M2TS's (and 'VOB's) to H264/MKV.
[1] The p24/1.001 & soft-telecined titles are to be 55-telecined to p60/1.001 via my ffmpeg method.
[2] The i30/1.001 hard-telecined titles are to be detelecined and then 55-telecined to p60/1.001 via my ffmpeg method.
[3] The i30/1.001 (MPEG-interlace) titles & the mixed titles (e.g., "Making of" documentaries), are to be deinterlaced or line-doubled to p60/1.001 via ffmpeg.
There will be no menus, so I don't care about playlists, so I don't look at 'MPLS' or 'IFO' files. Also, MPV accepts only 'M2TS's & 'VOB's.

I could have a single script that processes all titles (and toss out the cruft in the morning), but then the script would need to be capable of automatically descriminating between [1] & [2] & [3], and that seems impossilble. That's why I look at the 'M2TS's & 'VOB's with MPV and select the appropriate script: [1] or [2] or [3], for each.

Now, to be clear, if 'HandBrake-GUI' did 55-telecine, or if it could run

Code: Select all

ffmpeg -i IN -filter_complex "telecine=pattern=5,split[A][B],[A]select='not(eq(mod((n+1)\,5)\,3))'[C],[B]select='eq(mod((n+1)\,5)\,3)',pp=linblenddeint[D],[C][D]interleave" -map 0 -codec:v libx264 -crf 18 -codec:a copy -sn -dn OUT
as a preset/plug-in, then this entire problem would go away: I would simply enqueue a pile of titles (for which I have selected the appropriate preset/plug-ins) and I'd go to sleep (or do my spring housecleaning or do my house renovation) and come back later. That would make me very happy.

If 'HandBrake-GUI' will never do 55-telecine and will never support ffmpeg-based preset plug-ins, then I'm left with the Windows script problems.
The most direct problem is that, given an 'M2TS' file passed into a script as %1, there's no 'handbrakecli' way to fetch its title# (to insert into subsequent commands).

I've developed a way to show the user just the "+" entries from 'HandBrakeCLI --title 0', and I'm pretty confident that I'll find a way for the user to select the desired 'title#', but linking the 'title#' (which 'handbrakecli' finds in playlists) with the 'M2TS' file (that the user selected) is a gulf that can't be bridged without a method. I don't have such a method and 'handbrakecli' doesn't appear to have such a method.
rollin_eng
Veteran User
Posts: 3611
Joined: Wed May 04, 2011 11:06 pm

Re: get-them-all-no-matter-what setting for subtitles?

Post by rollin_eng »

From the link above eac3to:

- can extract Blu-Ray and HD DVD chapter information and subtitles

HB is a video encoder, it will always encode your video. You want a Muxer to get the subs and chapters, eac3to will extract just the subs and chapters if you tell it to.

eac3to will also tell you which m2ts files are in which playlist.
markfilipak
Bright Spark User
Posts: 237
Joined: Thu Aug 01, 2019 8:58 pm

Re: get-them-all-no-matter-what setting for subtitles?

Post by markfilipak »

rollin_eng wrote: Mon May 04, 2020 8:00 am From the link above eac3to:

- can extract Blu-Ray and HD DVD chapter information and subtitles
Thank you. I do understand that, but I'm unsure how to 'save' the chaps & subs and I'm unsure how to then merge them with video & audio.
HB is a video encoder, it will always encode your video. You want a Muxer to get the subs and chapters, eac3to will extract just the subs and chapters if you tell it to.

eac3to will also tell you which m2ts files are in which playlist.
I've not experimented with that, but even if I can do it, I'm very skeptical that it can be scripted.

I've posted this: viewtopic.php?f=6&t=40083&p=189957#p189957. I'm very interested in what you think of it.

Regards,
Mark.
rollin_eng
Veteran User
Posts: 3611
Joined: Wed May 04, 2011 11:06 pm

Re: get-them-all-no-matter-what setting for subtitles?

Post by rollin_eng »

While HB uses ffmpeg libraries it is not just a front end for ffmpeg. This means not all options from ffmpeg are available/compatible with HB.

If you look at eac3to options it will tell you haw to export subs.

I suggested Ribot264 as it seems more suited to your situation as it is a front end to ffmpeg so you might be able to implement your ffmpeg commands within it.

Edit: Ripbot264 basically does what you are doing/want to do, it demuxes all your tracks, sends them off to various programs then muxes them back together.
mduell
Veteran User
Posts: 7264
Joined: Sat Apr 21, 2007 8:54 pm

Re: get-them-all-no-matter-what setting for subtitles?

Post by mduell »

markfilipak wrote: Sat May 02, 2020 7:55 pmYou know. all this rigamarole would be unneeded if either, 1, HB could remux, or 2, HB did 55-telecine.
You still haven't proposed a patch for either of those? It's been weeks!
Post Reply