Parse -t0 output

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.
Post Reply
bjrnfrdnnd
Posts: 10
Joined: Tue Jan 25, 2011 9:51 pm

Parse -t0 output

Post by bjrnfrdnnd »

Hello,

I would like to use Handbrake in order to copy dvd's or blurays to mkv or m4v.
I would like, in general, to copy all titles, all audio tracks, and all subtitle tracks.
For all audio tracks, it would probably be best to conserve the original track and also reencode to
dts.
If I had all the information concerning all titles and all audio and subtitle tracks, I could probably write a loop that
does all of this.
Using the -t0 option, one can parse the output of Handbrake in order to extract all the required information,
or I have the impression that all the information is coded in this output.
But I suspect that the Handbrake Gui is a frontend to the HandBrake CLI, so I suspect there must be some
useful parsers out there that already are able to parse the -t0 output and store the result in some kind of
object that has all these informations?
If anyone has informations on such a parser, or if anyone has a script that copies the entire dvd structure to mkv or m4v,
please help me out.

PS: as this is a general question about how to do things, there is no activity log associated to it. Hope this gets posted anyways.
Deleted User 11865

Re: Parse -t0 output

Post by Deleted User 11865 »

Only the WinGUI is a CLI wrapper. Other UIs access libhb directly.

Feel free to have a look at the WinGUI source code and decide if any of its code is useful to your goal.

HandBrake has no DTS encoder.
FelixB
Posts: 13
Joined: Sat Feb 23, 2019 3:31 pm

Re: Parse -t0 output

Post by FelixB »

Hi,
Did you ever manage to parse and process output from -t 0 ?
User avatar
JohnAStebbins
HandBrake Team
Posts: 5712
Joined: Sat Feb 09, 2008 7:21 pm

Re: Parse -t0 output

Post by JohnAStebbins »

Nice necro-post :mrgreen:

Anyway, you might find it easier to use the '--json' option of HandBrakeCLI. It outputs the title information in json format. stdout looks like this:

Code: Select all

Version: {
    "Arch": "x86_64",
    "Name": "HandBrake",
    "Official": true,
    "RepoDate": "2019-02-21 16:19:39",
    "RepoHash": "c6cde0de9f3f6b1d50b5dc736cbb3fb30d4ffdb8",
    "System": "Linux",
    "Type": "developer",
    "Version": {
        "Major": 0,
        "Minor": 0,
        "Point": 0
    },
    "VersionString": "20190221161939-c6cde0d-master"
}
Progress: {
    "Scanning": {
        "Preview": 10,
        "PreviewCount": 10,
        "Progress": 1.0,
        "Title": 2,
        "TitleCount": 2
    },
    "State": "SCANNING"
}
JSON Title Set: {
    "MainFeature": 1,
    "TitleList": [
        {
            "AngleCount": 1,
            "AudioList": [
                {
                    "Attributes": {
                        "AltCommentary": false,
                        "Commentary": false,
                        "Default": false,
                        "Normal": true,
                        "Secondary": false,
                        "VisuallyImpaired": false
                    },
                    "BitRate": 192000,
                    "ChannelCount": 2,
                    "ChannelLayout": 3,
                    "ChannelLayoutName": "stereo",
                    "Codec": 2048,
                    "CodecName": "ac3",
                    "Description": "English (AC3) (2.0 ch) (192 kbps)",
                    "LFECount": 0,
                    "Language": "English",
                    "LanguageCode": "eng",
                    "SampleRate": 48000
                },
                {
                    "Attributes": {
                        "AltCommentary": false,
                        "Commentary": false,
                        "Default": false,
                        "Normal": true,
                        "Secondary": false,
                        "VisuallyImpaired": false
                    },
                    "BitRate": 448000,
                    "ChannelCount": 6,
                    "ChannelLayout": 1551,
                    "ChannelLayoutName": "5.1(side)",
                    "Codec": 2048,
                    "CodecName": "ac3",
                    "Description": "English (AC3) (5.1 ch) (448 kbps)",
                    "LFECount": 1,
                    "Language": "English",
                    "LanguageCode": "eng",
                    "SampleRate": 48000
                },
                {
                    "Attributes": {
                        "AltCommentary": false,
                        "Commentary": false,
                        "Default": false,
                        "Normal": true,
                        "Secondary": false,
                        "VisuallyImpaired": false
                    },
                    "BitRate": 192000,
                    "ChannelCount": 2,
                    "ChannelLayout": 1610612736,
                    "ChannelLayoutName": "downmix",
                    "Codec": 2048,
                    "CodecName": "ac3",
                    "Description": "Francais (AC3) (2.0 ch) (Dolby Surround) (192 kbps)",
                    "LFECount": 0,
                    "Language": "Francais",
                    "LanguageCode": "fra",
                    "SampleRate": 48000
                },
                {
                    "Attributes": {
                        "AltCommentary": false,
                        "Commentary": true,
                        "Default": false,
                        "Normal": false,
                        "Secondary": false,
                        "VisuallyImpaired": false
                    },
                    "BitRate": 128000,
                    "ChannelCount": 2,
                    "ChannelLayout": 3,
                    "ChannelLayoutName": "stereo",
                    "Codec": 2048,
                    "CodecName": "ac3",
                    "Description": "English (AC3) (Director's Commentary 1) (2.0 ch) (128 kbps)",
                    "LFECount": 0,
                    "Language": "English",
                    "LanguageCode": "eng",
                    "SampleRate": 48000
                },
                {
                    "Attributes": {
                        "AltCommentary": false,
                        "Commentary": false,
                        "Default": false,
                        "Normal": true,
                        "Secondary": false,
                        "VisuallyImpaired": false
                    },
                    "BitRate": 128000,
                    "ChannelCount": 2,
                    "ChannelLayout": 3,
                    "ChannelLayoutName": "stereo",
                    "Codec": 2048,
                    "CodecName": "ac3",
                    "Description": "English (AC3) (2.0 ch) (128 kbps)",
                    "LFECount": 0,
                    "Language": "English",
                    "LanguageCode": "eng",
                    "SampleRate": 48000
                },
                {
                    "Attributes": {
                        "AltCommentary": false,
                        "Commentary": false,
                        "Default": false,
                        "Normal": true,
                        "Secondary": false,
                        "VisuallyImpaired": false
                    },
                    "BitRate": 128000,
                    "ChannelCount": 2,
                    "ChannelLayout": 3,
                    "ChannelLayoutName": "stereo",
                    "Codec": 2048,
                    "CodecName": "ac3",
                    "Description": "English (AC3) (2.0 ch) (128 kbps)",
                    "LFECount": 0,
                    "Language": "English",
                    "LanguageCode": "eng",
                    "SampleRate": 48000
                }
            ],
            "ChapterList": [
                {
                    "Duration": {
                        "Hours": 0,
                        "Minutes": 4,
                        "Seconds": 41,
                        "Ticks": 25263000
                    },
                    "Name": "Chapter 1"
                },
                {
                    "Duration": {
                        "Hours": 0,
                        "Minutes": 8,
                        "Seconds": 5,
                        "Ticks": 43620030
                    },
                    "Name": "Chapter 2"
                },
                {
                    "Duration": {
                        "Hours": 0,
                        "Minutes": 7,
                        "Seconds": 48,
                        "Ticks": 42086970
                    },
                    "Name": "Chapter 3"
                },
                {
                    "Duration": {
                        "Hours": 0,
                        "Minutes": 7,
                        "Seconds": 33,
                        "Ticks": 40799970
                    },
                    "Name": "Chapter 4"
                },
                {
                    "Duration": {
                        "Hours": 0,
                        "Minutes": 2,
                        "Seconds": 58,
                        "Ticks": 15990030
                    },
                    "Name": "Chapter 5"
                },
                {
                    "Duration": {
                        "Hours": 0,
                        "Minutes": 5,
                        "Seconds": 12,
                        "Ticks": 28065060
                    },
                    "Name": "Chapter 6"
                },
                {
                    "Duration": {
                        "Hours": 0,
                        "Minutes": 10,
                        "Seconds": 6,
                        "Ticks": 54510030
                    },
                    "Name": "Chapter 7"
                },
                {
                    "Duration": {
                        "Hours": 0,
                        "Minutes": 4,
                        "Seconds": 30,
                        "Ticks": 24300000
                    },
                    "Name": "Chapter 8"
                },
                {
                    "Duration": {
                        "Hours": 0,
                        "Minutes": 3,
                        "Seconds": 42,
                        "Ticks": 19943910
                    },
                    "Name": "Chapter 9"
                },
                {
                    "Duration": {
                        "Hours": 0,
                        "Minutes": 3,
                        "Seconds": 28,
                        "Ticks": 18675000
                    },
                    "Name": "Chapter 10"
                },
                {
                    "Duration": {
                        "Hours": 0,
                        "Minutes": 5,
                        "Seconds": 27,
                        "Ticks": 29432970
                    },
                    "Name": "Chapter 11"
                },
                {
                    "Duration": {
                        "Hours": 0,
                        "Minutes": 7,
                        "Seconds": 28,
                        "Ticks": 40347000
                    },
                    "Name": "Chapter 12"
                },
                {
                    "Duration": {
                        "Hours": 0,
                        "Minutes": 9,
                        "Seconds": 33,
                        "Ticks": 51600060
                    },
                    "Name": "Chapter 13"
                },
                {
                    "Duration": {
                        "Hours": 0,
                        "Minutes": 3,
                        "Seconds": 35,
                        "Ticks": 19335060
                    },
                    "Name": "Chapter 14"
                },
                {
                    "Duration": {
                        "Hours": 0,
                        "Minutes": 5,
                        "Seconds": 1,
                        "Ticks": 27074970
                    },
                    "Name": "Chapter 15"
                },
                {
                    "Duration": {
                        "Hours": 0,
                        "Minutes": 5,
                        "Seconds": 39,
                        "Ticks": 30528000
                    },
                    "Name": "Chapter 16"
                },
                {
                    "Duration": {
                        "Hours": 0,
                        "Minutes": 7,
                        "Seconds": 20,
                        "Ticks": 39582000
                    },
                    "Name": "Chapter 17"
                },
                {
                    "Duration": {
                        "Hours": 0,
                        "Minutes": 3,
                        "Seconds": 40,
                        "Ticks": 19824030
                    },
                    "Name": "Chapter 18"
                },
                {
                    "Duration": {
                        "Hours": 0,
                        "Minutes": 8,
                        "Seconds": 0,
                        "Ticks": 43229970
                    },
                    "Name": "Chapter 19"
                },
                {
                    "Duration": {
                        "Hours": 0,
                        "Minutes": 2,
                        "Seconds": 48,
                        "Ticks": 15093000
                    },
                    "Name": "Chapter 20"
                },
                {
                    "Duration": {
                        "Hours": 0,
                        "Minutes": 0,
                        "Seconds": 1,
                        "Ticks": 45000
                    },
                    "Name": "Chapter 21"
                }
            ],
            "Color": {
                "Matrix": 6,
                "Primary": 6,
                "Transfer": 1
            },
            "Crop": [
                56,
                58,
                0,
                2
            ],
            "Duration": {
                "Hours": 1,
                "Minutes": 56,
                "Seconds": 32,
                "Ticks": 629346060
            },
            "FrameRate": {
                "Den": 1126125,
                "Num": 27000000
            },
            "Geometry": {
                "Height": 480,
                "PAR": {
                    "Den": 27,
                    "Num": 32
                },
                "Width": 720
            },
            "Index": 1,
            "InterlaceDetected": false,
            "Metadata": {},
            "Name": "ALIEN",
            "Path": "/Samples/DVD/Alien.iso",
            "Playlist": -1,
            "SubtitleList": [
                {
                    "Attributes": {
                        "4By3": false,
                        "Children": false,
                        "ClosedCaption": true,
                        "Commentary": false,
                        "Default": false,
                        "Forced": false,
                        "Large": false,
                        "Letterbox": false,
                        "Normal": false,
                        "PanScan": false,
                        "Wide": true
                    },
                    "Format": "bitmap",
                    "Language": "English Closed Caption (Wide Screen) [VOBSUB]",
                    "LanguageCode": "eng",
                    "Source": 0,
                    "SourceName": "VOBSUB"
                },
                {
                    "Attributes": {
                        "4By3": false,
                        "Children": false,
                        "ClosedCaption": true,
                        "Commentary": false,
                        "Default": false,
                        "Forced": false,
                        "Large": false,
                        "Letterbox": true,
                        "Normal": false,
                        "PanScan": false,
                        "Wide": false
                    },
                    "Format": "bitmap",
                    "Language": "English Closed Caption (Letterbox) [VOBSUB]",
                    "LanguageCode": "eng",
                    "Source": 0,
                    "SourceName": "VOBSUB"
                },
                {
                    "Attributes": {
                        "4By3": false,
                        "Children": false,
                        "ClosedCaption": false,
                        "Commentary": false,
                        "Default": false,
                        "Forced": false,
                        "Large": false,
                        "Letterbox": false,
                        "Normal": true,
                        "PanScan": false,
                        "Wide": true
                    },
                    "Format": "bitmap",
                    "Language": "español (Wide Screen) [VOBSUB]",
                    "LanguageCode": "spa",
                    "Source": 0,
                    "SourceName": "VOBSUB"
                },
                {
                    "Attributes": {
                        "4By3": false,
                        "Children": false,
                        "ClosedCaption": false,
                        "Commentary": false,
                        "Default": false,
                        "Forced": false,
                        "Large": false,
                        "Letterbox": true,
                        "Normal": true,
                        "PanScan": false,
                        "Wide": false
                    },
                    "Format": "bitmap",
                    "Language": "español (Letterbox) [VOBSUB]",
                    "LanguageCode": "spa",
                    "Source": 0,
                    "SourceName": "VOBSUB"
                },
                {
                    "Attributes": {
                        "4By3": false,
                        "Children": false,
                        "ClosedCaption": false,
                        "Commentary": false,
                        "Default": false,
                        "Forced": false,
                        "Large": false,
                        "Letterbox": false,
                        "Normal": true,
                        "PanScan": false,
                        "Wide": true
                    },
                    "Format": "bitmap",
                    "Language": "Francais (Wide Screen) [VOBSUB]",
                    "LanguageCode": "fra",
                    "Source": 0,
                    "SourceName": "VOBSUB"
                },
                {
                    "Attributes": {
                        "4By3": false,
                        "Children": false,
                        "ClosedCaption": false,
                        "Commentary": false,
                        "Default": false,
                        "Forced": false,
                        "Large": false,
                        "Letterbox": true,
                        "Normal": true,
                        "PanScan": false,
                        "Wide": false
                    },
                    "Format": "bitmap",
                    "Language": "Francais (Letterbox) [VOBSUB]",
                    "LanguageCode": "fra",
                    "Source": 0,
                    "SourceName": "VOBSUB"
                },
                {
                    "Attributes": {
                        "4By3": false,
                        "Children": false,
                        "ClosedCaption": true,
                        "Commentary": false,
                        "Default": false,
                        "Forced": false,
                        "Large": false,
                        "Letterbox": false,
                        "Normal": false,
                        "PanScan": false,
                        "Wide": false
                    },
                    "Format": "text",
                    "Language": "English, Closed Caption [CC608]",
                    "LanguageCode": "eng",
                    "Source": 1,
                    "SourceName": "CC608"
                }
            ],
            "Type": 0,
            "VideoCodec": "mpeg2video"
        },
        {
            "AngleCount": 1,
            "AudioList": [
                {
                    "Attributes": {
                        "AltCommentary": false,
                        "Commentary": false,
                        "Default": false,
                        "Normal": false,
                        "Secondary": false,
                        "VisuallyImpaired": false
                    },
                    "BitRate": 192000,
                    "ChannelCount": 2,
                    "ChannelLayout": 3,
                    "ChannelLayoutName": "stereo",
                    "Codec": 2048,
                    "CodecName": "ac3",
                    "Description": "English (AC3) (2.0 ch) (192 kbps)",
                    "LFECount": 0,
                    "Language": "English",
                    "LanguageCode": "eng",
                    "SampleRate": 48000
                },
                {
                    "Attributes": {
                        "AltCommentary": false,
                        "Commentary": false,
                        "Default": false,
                        "Normal": true,
                        "Secondary": false,
                        "VisuallyImpaired": false
                    },
                    "BitRate": 192000,
                    "ChannelCount": 2,
                    "ChannelLayout": 3,
                    "ChannelLayoutName": "stereo",
                    "Codec": 2048,
                    "CodecName": "ac3",
                    "Description": "English (AC3) (2.0 ch) (192 kbps)",
                    "LFECount": 0,
                    "Language": "English",
                    "LanguageCode": "eng",
                    "SampleRate": 48000
                }
            ],
            "ChapterList": [
                {
                    "Duration": {
                        "Hours": 0,
                        "Minutes": 3,
                        "Seconds": 23,
                        "Ticks": 18249030
                    },
                    "Name": "Chapter 1"
                },
                {
                    "Duration": {
                        "Hours": 0,
                        "Minutes": 0,
                        "Seconds": 1,
                        "Ticks": 45000
                    },
                    "Name": "Chapter 2"
                },
                {
                    "Duration": {
                        "Hours": 0,
                        "Minutes": 0,
                        "Seconds": 1,
                        "Ticks": 45000
                    },
                    "Name": "Chapter 3"
                }
            ],
            "Color": {
                "Matrix": 6,
                "Primary": 6,
                "Transfer": 1
            },
            "Crop": [
                108,
                110,
                14,
                22
            ],
            "Duration": {
                "Hours": 0,
                "Minutes": 3,
                "Seconds": 23,
                "Ticks": 18338940
            },
            "FrameRate": {
                "Den": 1126125,
                "Num": 27000000
            },
            "Geometry": {
                "Height": 480,
                "PAR": {
                    "Den": 9,
                    "Num": 8
                },
                "Width": 720
            },
            "Index": 3,
            "InterlaceDetected": false,
            "Metadata": {},
            "Name": "ALIEN",
            "Path": "/Samples/DVD/Alien.iso",
            "Playlist": -1,
            "SubtitleList": [],
            "Type": 0,
            "VideoCodec": "mpeg2video"
        }
    ]
}
FelixB
Posts: 13
Joined: Sat Feb 23, 2019 3:31 pm

Re: Parse -t0 output

Post by FelixB »

Thanks!!!
How do you process the output?
Do you parse the output as a text file?
User avatar
s55
HandBrake Team
Posts: 10350
Joined: Sun Dec 24, 2006 1:05 pm

Re: Parse -t0 output

Post by s55 »

That's entirely up to you.
FelixB
Posts: 13
Joined: Sat Feb 23, 2019 3:31 pm

Re: Parse -t0 output

Post by FelixB »

Thanks, I know I am asking stupid newbie questions:):)

Anyways, I've figured out how to parse the JSON data to a variable, now I only have to figure out how to crunch the data with the help of the ConvertFrom-Json cmdlet in Powershell that I've never used before:)
Post Reply