linux cli blu-ray automation

The place to discuss linux version of MakeMKV
Post Reply
brw02005
Posts: 3
Joined: Wed May 12, 2010 1:14 am

linux cli blu-ray automation

Post by brw02005 »

Trying to automate ripping blu-ray with a script. I would like it to pick the largest track or track with the most chapters and grab all the english sound and subtitle tracks. If this is not possible at this time that is fine. I am just happy this thing works as well as it does.

Thank you for your time.
mike admin
Posts: 4075
Joined: Wed Nov 26, 2008 2:26 am
Contact:

Re: linux cli blu-ray automation

Post by mike admin »

You can inspect all titles and tracks with -r switch, but you can't select individual tracks yet.
BitJam2
Posts: 53
Joined: Wed Sep 01, 2010 7:04 am

Re: linux cli blu-ray automation

Post by BitJam2 »

For me, with MakeMKV v1.5.8 linux(x64-release) the -r command line switch does not add any useful track information to the output. It does display the title of the disc which is nice. For example:

Code: Select all

$ makemkvcon -r stream disc:0
MSG:1005,0,1,"MakeMKV v1.5.8 linux(x64-release) started","%1 started","MakeMKV v1.5.8 linux(x64-release)"
DRV:0,1,1,12,"BD-ROM ASUS BR-04B2T 1.01","TEKKONKINKREET"
DRV:1,1,1,512,"DVD+R-DL ATAPI iHAS422   8 4L17",""
DRV:2,0,0,0,"",""
DRV:3,0,0,0,"",""
DRV:4,0,0,0,"",""
DRV:5,0,0,0,"",""
DRV:6,0,0,0,"",""
DRV:7,0,0,0,"",""
DRV:8,0,0,0,"",""
DRV:9,0,0,0,"",""
DRV:10,0,0,0,"",""
DRV:11,0,0,0,"",""
DRV:12,0,0,0,"",""
DRV:13,0,0,0,"",""
DRV:14,0,0,0,"",""
DRV:15,0,0,0,"",""
MSG:3007,0,0,"Using direct disc access mode","Using direct disc access mode"
MSG:3025,0,3,"Title #00099.mpls has length of 96 seconds which is less than minimum title length of 120 seconds and was therefore skipped","Title #%1 has length of %2 seconds which is less than minimum title length of %3 seconds and was therefore skipped","00099.mpls","96","120"
MSG:3307,0,2,"File 00001.mpls was added as title #0","File %1 was added as title #%2","00001.mpls","0"
MSG:3025,0,3,"Title #00102.mpls has length of 60 seconds which is less than minimum title length of 120 seconds and was therefore skipped","Title #%1 has length of %2 seconds which is less than minimum title length of %3 seconds and was therefore skipped","00102.mpls","60","120"
MSG:3025,0,3,"Title #00000.m2ts has length of 14 seconds which is less than minimum title length of 120 seconds and was therefore skipped","Title #%1 has length of %2 seconds which is less than minimum title length of %3 seconds and was therefore skipped","00000.m2ts","14","120"
MSG:3025,0,3,"Title #00001.m2ts has length of 48 seconds which is less than minimum title length of 120 seconds and was therefore skipped","Title #%1 has length of %2 seconds which is less than minimum title length of %3 seconds and was therefore skipped","00001.m2ts","48","120"
MSG:3025,0,3,"Title #00021.m2ts has length of 9 seconds which is less than minimum title length of 120 seconds and was therefore skipped","Title #%1 has length of %2 seconds which is less than minimum title length of %3 seconds and was therefore skipped","00021.m2ts","9","120"
MSG:3025,0,3,"Title #00022.m2ts has length of 9 seconds which is less than minimum title length of 120 seconds and was therefore skipped","Title #%1 has length of %2 seconds which is less than minimum title length of %3 seconds and was therefore skipped","00022.m2ts","9","120"
MSG:3025,0,3,"Title #00081.m2ts has length of 60 seconds which is less than minimum title length of 120 seconds and was therefore skipped","Title #%1 has length of %2 seconds which is less than minimum title length of %3 seconds and was therefore skipped","00081.m2ts","60","120"
MSG:3025,0,3,"Title #00082.m2ts has length of 0 seconds which is less than minimum title length of 120 seconds and was therefore skipped","Title #%1 has length of %2 seconds which is less than minimum title length of %3 seconds and was therefore skipped","00082.m2ts","0","120"
MSG:3025,0,3,"Title #00083.m2ts has length of 0 seconds which is less than minimum title length of 120 seconds and was therefore skipped","Title #%1 has length of %2 seconds which is less than minimum title length of %3 seconds and was therefore skipped","00083.m2ts","0","120"
MSG:3307,0,2,"File 00091.m2ts was added as title #1","File %1 was added as title #%2","00091.m2ts","1"
MSG:3307,0,2,"File 00092.m2ts was added as title #2","File %1 was added as title #%2","00092.m2ts","2"
MSG:3025,0,3,"Title #00093.m2ts has length of 73 seconds which is less than minimum title length of 120 seconds and was therefore skipped","Title #%1 has length of %2 seconds which is less than minimum title length of %3 seconds and was therefore skipped","00093.m2ts","73","120"
MSG:3025,0,3,"Title #00094.m2ts has length of 83 seconds which is less than minimum title length of 120 seconds and was therefore skipped","Title #%1 has length of %2 seconds which is less than minimum title length of %3 seconds and was therefore skipped","00094.m2ts","83","120"
MSG:3307,0,2,"File 00095.m2ts was added as title #3","File %1 was added as title #%2","00095.m2ts","3"
MSG:3307,0,2,"File 00096.m2ts was added as title #4","File %1 was added as title #%2","00096.m2ts","4"
MSG:3025,0,3,"Title #00097.m2ts has length of 74 seconds which is less than minimum title length of 120 seconds and was therefore skipped","Title #%1 has length of %2 seconds which is less than minimum title length of %3 seconds and was therefore skipped","00097.m2ts","74","120"
MSG:3307,0,2,"File 00098.m2ts was added as title #5","File %1 was added as title #%2","00098.m2ts","5"
MSG:3025,0,3,"Title #00100.m2ts has length of 1 seconds which is less than minimum title length of 120 seconds and was therefore skipped","Title #%1 has length of %2 seconds which is less than minimum title length of %3 seconds and was therefore skipped","00100.m2ts","1","120"
MSG:3307,0,2,"File 00101.m2ts was added as title #6","File %1 was added as title #%2","00101.m2ts","6"
MSG:5011,0,0,"Operation sucessfully completed","Operation sucessfully completed"
MSG:4500,0,2,"Streaming server started, web server address is http://192.168.0.10:51000 or http://localhost:51000","Streaming server started, web server address is http://%1 or http://localhost:%2","192.168.0.10:51000","51000"
MSG:4503,0,1,"UPnP server enabled on address 192.168.0.10","UPnP server enabled on address %1","192.168.0.10"
Ironically, with or without the -r flag, we get the lengths of the tracks that aren't available for streaming but not the lengths of the tracks that are. Perhaps I'm stating the obvious, but ISTM all that is required is to add the length (total seconds is fine) at the end of lines like:

File 00001.mpls was added as title #0

So they become something like:

File 00001.mpls was added as title #0 Length: XXXX seconds

That is pretty easy for both humans and programs to deal with (IMO).
mike admin
Posts: 4075
Joined: Wed Nov 26, 2008 2:26 am
Contact:

Re: linux cli blu-ray automation

Post by mike admin »

I see. You'll get all information if you use 'info' command with '-r' switch. Can you launch makemkv two times?
BitJam2
Posts: 53
Joined: Wed Sep 01, 2010 7:04 am

Re: linux cli blu-ray automation

Post by BitJam2 »

Yes, "makemkvcon -r info disc:0" does give me the length of the tracks. Thank you. The length of each track is in a line like:

TINFO:$TRACK,9,0,"$TIME"

I could write a Perl program to parse that.I'm not sure what is the best way to deal with this information. I'm thinking of creating either a video playlist .asx file and/or creating a gtkdialog script that would create a simple GUI interface to the tracks. I'd also like to make the information about the subtitles and audio tracks available.

Running makemkv twice is not ideal because of the added delay. But on the plus side, it is something that is working today. Perfect is the enemy of good.
mike admin
Posts: 4075
Joined: Wed Nov 26, 2008 2:26 am
Contact:

Re: linux cli blu-ray automation

Post by mike admin »

Make sure to specify --cache for the first time and --noscan for the second.
BitJam2
Posts: 53
Joined: Wed Sep 01, 2010 7:04 am

Re: linux cli blu-ray automation

Post by BitJam2 »

H'mm. The --cache option does not work with the -r option in "info" mode. If I do:

$ makemkvcon --cache -r info disc:0

then the -r option is ignored. If I do:

$ makemkvcon -r --cache info disc:0

then it tells me: "Invalid command: disc:0".

It is possible to run "info" while "stream" is still running but I want to run "info" first because I want to stream each Blu-ray title on a different port so xbmc will remember where the user last stopped on each Blu-ray. That way xbmc will offer to resume a Blu-ray where the user last stopped (if the stream is accessed via a .asx playlist file which I'm planning to create automatically). This is the only reliable stream seeking I've found in xbmc. I'm able to seek great in vlc but I haven't gotten VDPAU working well (if at all) in vlc. It won't play "Avatar" at all and it stumbles playing "Harry Potter atCoS". Vlc was able to play other Blu-rays okay but so far xbmc is the only player that reliably plays every Blu-ray stream I've tried and uses VDPAU (Nvidia's GPU hardware acceleration) for the playback. I'd love to have random access seeking but I'll settle for resuming where I left off. Since vlc seeks, the seeking problem is in the players not makemkv.

This is not a show stopper, it just means I can't use caching for now (unless PEBKaC).

IMO, part of the ideal solution would be to simply include the disc title and track lengths in the standard (no -r) "stream" and "info" output. Likewise, IMO the standard "info" output should include the language of each track and subtitle. I'd also get rid of the information about skipped tracks unless requested by some option flag. Perhaps I'm missing something, but for me, the standard (no -r) output is much easier to parse than the -r output.

Again, the current MakeMKV v1.5.8 works well enough for me to write my program.

Edit: I take it back. Lines starting with CINFO|TINFO|SINFO are very easy to parse by machine with the information provided in apdefs.h. Well done.

Here is a simple parser written in Perl. The lines output from `makemkvcon -r info disc:0` are feed into read_bluray().

Code: Select all

my %INFO = (
     0 => "unknown",
     1 => "type",
     2 => "title",
     3 => "lang_code",
     4 => "lang",
     5 => "codec_id",
     6 => "codec_short",
     7 => "codec_long",
     8 => "chapters",
     9 => "duration",
    10 => "size",
    11 => "bytes",
    12 => "extension",
    13 => "bitrate",
    14 => "audio_channels",
    15 => "angle_info",
    16 => "fname",
    17 => "sample_rate",
    18 => "sample_size",
    19 => "video_size",
    20 => "aspect_ratio",
    21 => "frame_rate",
    22 => "stream_flags",
    23 => "date_time",
);

sub read_bluray {
    my $self = {};
    for (@_) {
        m/^TCOUNT:(\d+)/ and $self->{tcount} = $1;
        m/^CINFO:(\d+),\d+,"(.*)"/ 
            and add_cinfo($self, $1, $2);
        m/^TINFO:(\d+),(\d+),\d+,"(.*)"/
            and add_tinfo($self, $1, $2, $3);
        m/^SINFO:(\d+),(\d+),(\d+),\d+,"(.*)"/
            and add_sinfo($self, $1, $2, $3, $4);
    }
    return $self;
}

sub add_cinfo {
    my ($self, $id, $val) = @_;
    my $key = $INFO{$id};
    $self->{$key} = $val;
}

sub add_tinfo {
    my ($self, $track, $id, $val) = @_;
    my $key = $INFO{$id};
    $self->{_track}[$track]{$key} = $val;
}

sub add_sinfo {
    my ($self, $track, $chan, $id, $val) = @_;
    my $key = $INFO{$id};
    $self->{_track}[$track]{chan}[$chan]{$key} = $val;
}
Post Reply