1

When using HandBrake, it found it quite a nice feature that it can recognize the correct movie name that is on a DVD (of course not all, but a lot). When using HandBrake CLI, I could not find an option to do that autodiscovery.

Did I miss something? How does the GUI do it? Any recommendations for getting the movie name from the commandline? It does not need to be HandBrake CLI, I can stitch it together myself.

For clarification of my question: I am not after the movie title number (as in the argument to the -t option), but after the movie name, as in "Lock, Stock and Two Smoking Barrels". The gui does recognize this, at least for some DVDs. How is that acomplished?

6 Answers 6

1

I have not found this feature in the CLI myself. According to this: https://forum.handbrake.fr/viewtopic.php?f=6&t=15874#p74897 (opens from Help->Guide in my Handbrake), Handbrake (GUI) by default selects the longest title as this is usually the main feature.

If you supply 0 to the -t option for CLI, it will list all the titles so that you can select the longest.

Another technique I have used is what is described in the solution section in the forum post above, simply start the DVD in VLC and then check which title is playing.

1
  • I seem to have miss phrased my question ... What I was after was the name of the movie, like "The Simpsons Movie", "Lock, Stock and Two Smoking Barrels", ... I have updated my question.
    – Isaac
    Nov 27, 2015 at 8:02
1

I finally found a solution with the help of the HandBrake Forum:

HandBrakeCLI --scan  -i /dev/sr0 | awk -F: '/DVD Title/ {print $3}' |python -c "import sys; print(sys.stdin.read().title().replace('_', ' '))" |head -1

So what this does is it filter libdvdnavs logoutput. Probably not a stable solution, because the log output of lbdvdnav is probably not to be considred a stable api. However it works for.

2
  • lsblk -n -o LABEL /dev/dvd is enough in certain moment!
    – lolotux
    Apr 3, 2022 at 23:48
  • you can use tr "_" " " instead of python
    – Eddie
    Nov 21, 2022 at 19:13
1

What I have been doing is to use `lsblk', i.e. (replace /dev/sr0 with the device file of your DVD device):

lsblk -n -o LABEL /dev/sr0

lsblk is part of util-linux (at least on Ubuntu), so it should already be installed.

If you wish to, you can process the label to make it nicer (like making it lowercase, changing underscores to dashes):

lsblk -n -o LABEL  /dev/sr0 | tr '[:upper:]' '[:lower:]' | sed -e 's/_/-/g'
1

Based on OP's discovery but eliminating need for python and awk, using posix standard utilities even busybox has!

HandBrakeCLI -I -i /dev/sr0 -o /dev/null/null.mp4 2>&1 | grep 'DVD Title:' | head -1 | rev | cut -f1 -d" " | rev | tr "_" " "

Read as: Get Info from disk, output(required, not used) to /dev/null, merge stderr/stdout, grep for DVD Title:, grab the first occurance, reverse the line, take the last (first) field, unreverse the line, replace underscores with spaces.

Result:

$> HandBrakeCLI -I -i /dev/sr0 -o /dev/nu/garabe.mp4ll 2>&1 | grep 'DVD Title:' | head -1 | rev | cut -f1 -d" " | rev | tr "_" " " 
THIS IS THE END
0

Here is a bit of powershell that reads the JSON output of handbrakecli, and forms it into an object with readable properties. The JSON output of HandbrakeCLI shoul be more robust then trying to parse the plaintext output. The source optical drive here is "D:", the source on linux would be /dev/xxx:

$titleList = ((HandbrakeCLI --scan --json -i 'D:\' | Join-String) -replace '.*JSON Title Set:\s*(.+)' , '$1' | ConvertFrom-JSON).TitleList

Now that you have the $titleList object, you can read the name as a property:

> $titleList.Name
TRIGUN1

Of course, you can skip the assignment to the $titleList variable if the only data you want is the name.

Powershell core is available for Windows, MacOS, and many (most?) major linux distros.

-1

or you could just do lsdvd LSDVD(1)

NAME lsdvd - read the content info of a DVD

SYNOPSIS lsdvd [ options ] [-t track_number] [dvd path]

DESCRIPTION An application for reading the contents of a DVD and printing the contents to your terminal and dump for further processing in external applications.

OPTIONS FOR EXTRA INFORMATION -a Dump information about audio streams.

   -d     Dump information about cells.

   -n     Dump information about angles (video layers).

   -c     Dump chapter information.

   -s     Dump subpicture information (e.g. subtitles).

   -P     Dump palette information.

   -v     Dump video information.

FORMATTING OPTIONS -Oh Dump output human readable (default setting).

   -Op    Dump output as a Perl hash. (Using -p is deprecated).

   -Oy    Dump output as Python.

   -Or    Dump output in Ruby format.

   -Ox    Dump output in XML.

: OTHER OPTIONS -h Display help.

   -q     Quiet output - do not summarize output.

   -V     Display version information.

LICENSE lsdvd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.

AUTHORS lsdvd was written by Chris Philips.

   This manual page was written by Moritz Muehlenhoff <[email protected]> for the Debian GNU/Linux system (but may be used by others).
1
  • This is not really an answer to the question. It is only an alternative.
    – zx485
    Jan 20, 2019 at 22:46

You must log in to answer this question.

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