mmkv_abi: A Python library for MakeMKV

Discussion of advanced MakeMKV functionality, expert mode, conversion profiles
Post Reply
me_dex
Posts: 2
Joined: Tue Jan 16, 2024 3:39 am
Contact:

mmkv_abi: A Python library for MakeMKV

Post by me_dex »

https://github.com/me-dex/mmkv_abi

Hewwo! I've created a Python library for interacting with MakeMKV. This library allows lower level access into MakeMKV's API's via makemkvcon's ABI which is usually utilized for the GUI. This means that more information can be gathered from both the disc and drive than by makemkvcon's CLI alone; basically any information that's available via the GUI is available via this library. This library also enables finer grain controls over the ripping process. These two features combined means that much more complex ripping logic can be written for automating large collection rips.

In the repo, I included an example script (example.py) which utilizes upper/lower bound duration cutoffs to detect which titles on a disc are episodes of a TV show as opposed to behind the scenes content/the whole playlist. An example run is below:

Code: Select all

$ python3 example.py
MakeMKV version: v1.17.5
MakeMKV platform: linux(x64-release)
MakeMKV build: 999
Interface language: eng:English
Waiting for disc...
Waiting for titles...


Title Tree:
The Good Place Season One: Disc One
├─ ✅ The Good Place Season One: Disc One - 0:42:42, 9 chapter(s), 9.7 GB
│  ├─ Chapters
│  │  ├─ Chapter 01 - 0:00:00
│  │  ├─ Chapter 02 - 0:03:16
│  │  ├─ Chapter 03 - 0:09:36
│  │  ├─ Chapter 04 - 0:20:38
│  │  ├─ Chapter 05 - 0:22:44
│  │  ├─ Chapter 06 - 0:29:35
│  │  ├─ Chapter 07 - 0:36:58
│  │  ├─ Chapter 08 - 0:41:04
│  │  └─ Chapter 09 - 0:42:00
│  └─ Tracks
│     ├─ ✅ Video - Mpeg4 AVC High@L4.1
│     ├─ ✅ Audio - DTS-HD Master Audio
│     ├─ ✅ Audio - DTS
│     ├─ ✅ Audio - Dolby Digital
│     ├─ ✅ Subtitles - HDMV PGS Subtitles
│     ├─ ✅ Subtitles - HDMV PGS Subtitles
│     └─ ✅ Attachment - image/jpeg
├─ ✅ The Good Place Season One: Disc One - 0:24:54, 6 chapter(s), 7.1 GB
│  ├─ Chapters
│  │  ├─ Chapter 01 - 0:00:00
│  │  ├─ Chapter 02 - 0:02:09
│  │  ├─ Chapter 03 - 0:06:14
│  │  ├─ Chapter 04 - 0:15:15
│  │  ├─ Chapter 05 - 0:21:34
│  │  └─ Chapter 06 - 0:24:02
│  └─ Tracks
│     ├─ ✅ Video - Mpeg4 AVC High@L4.1
│     ├─ ✅ Audio - DTS-HD Master Audio
│     ├─ ✅ Audio - DTS
│     ├─ ✅ Subtitles - HDMV PGS Subtitles
│     ├─ ✅ Subtitles - HDMV PGS Subtitles
│     └─ ✅ Attachment - image/jpeg
├─ ✅ The Good Place Season One: Disc One - 0:22:33, 6 chapter(s), 6.4 GB
│  ├─ Chapters
│  │  ├─ Chapter 01 - 0:00:00
│  │  ├─ Chapter 02 - 0:02:22
│  │  ├─ Chapter 03 - 0:08:37
│  │  ├─ Chapter 04 - 0:16:04
│  │  ├─ Chapter 05 - 0:20:30
│  │  └─ Chapter 06 - 0:21:42
│  └─ Tracks
│     ├─ ✅ Video - Mpeg4 AVC High@L4.1
│     ├─ ✅ Audio - DTS-HD Master Audio
│     ├─ ✅ Audio - DTS
│     ├─ ✅ Subtitles - HDMV PGS Subtitles
│     ├─ ✅ Subtitles - HDMV PGS Subtitles
│     └─ ✅ Attachment - image/jpeg
├─ ✅ The Good Place Season One: Disc One - 0:26:18, 6 chapter(s), 7.5 GB
│  ├─ Chapters
│  │  ├─ Chapter 01 - 0:00:00
│  │  ├─ Chapter 02 - 0:01:42
│  │  ├─ Chapter 03 - 0:09:07
│  │  ├─ Chapter 04 - 0:15:57
│  │  ├─ Chapter 05 - 0:19:56
│  │  └─ Chapter 06 - 0:25:27
│  └─ Tracks
│     ├─ ✅ Video - Mpeg4 AVC High@L4.1
│     ├─ ✅ Audio - DTS-HD Master Audio
│     ├─ ✅ Audio - DTS
│     ├─ ✅ Subtitles - HDMV PGS Subtitles
│     ├─ ✅ Subtitles - HDMV PGS Subtitles
│     └─ ✅ Attachment - image/jpeg
├─ ✅ The Good Place Season One: Disc One - 0:26:21, 6 chapter(s), 7.5 GB
│  ├─ Chapters
│  │  ├─ Chapter 01 - 0:00:00
│  │  ├─ Chapter 02 - 0:02:04
│  │  ├─ Chapter 03 - 0:10:25
│  │  ├─ Chapter 04 - 0:18:27
│  │  ├─ Chapter 05 - 0:23:37
│  │  └─ Chapter 06 - 0:25:30
│  └─ Tracks
│     ├─ ✅ Video - Mpeg4 AVC High@L4.1
│     ├─ ✅ Audio - DTS-HD Master Audio
│     ├─ ✅ Audio - DTS
│     ├─ ✅ Subtitles - HDMV PGS Subtitles
│     ├─ ✅ Subtitles - HDMV PGS Subtitles
│     └─ ✅ Attachment - image/jpeg
├─ ❎ The Good Place Season One: Disc One - 2:04:22, 34 chapter(s), 35.7 GB
│  ├─ Chapters
│  │  ├─ Chapter 01 - 0:00:00
│  │  ├─ Chapter 02 - 0:02:09
│  │  ├─ Chapter 03 - 0:06:14
│  │  ├─ Chapter 04 - 0:15:15
│  │  ├─ Chapter 05 - 0:21:34
│  │  ├─ Chapter 06 - 0:24:02
│  │  ├─ Chapter 07 - 0:24:53
│  │  ├─ Chapter 08 - 0:24:54
│  │  ├─ Chapter 09 - 0:27:17
│  │  ├─ Chapter 10 - 0:33:31
│  │  ├─ Chapter 11 - 0:40:59
│  │  ├─ Chapter 12 - 0:45:24
│  │  ├─ Chapter 13 - 0:46:36
│  │  ├─ Chapter 14 - 0:47:26
│  │  ├─ Chapter 15 - 0:47:27
│  │  ├─ Chapter 16 - 0:49:10
│  │  ├─ Chapter 17 - 0:56:35
│  │  ├─ Chapter 18 - 1:03:25
│  │  ├─ Chapter 19 - 1:07:24
│  │  ├─ Chapter 20 - 1:12:55
│  │  ├─ Chapter 21 - 1:13:45
│  │  ├─ Chapter 22 - 1:13:46
│  │  ├─ Chapter 23 - 1:15:50
│  │  ├─ Chapter 24 - 1:24:11
│  │  ├─ Chapter 25 - 1:32:13
│  │  ├─ Chapter 26 - 1:37:23
│  │  ├─ Chapter 27 - 1:39:16
│  │  ├─ Chapter 28 - 1:40:07
│  │  ├─ Chapter 29 - 1:40:08
│  │  ├─ Chapter 30 - 1:41:53
│  │  ├─ Chapter 31 - 1:47:38
│  │  ├─ Chapter 32 - 1:55:08
│  │  ├─ Chapter 33 - 2:00:47
│  │  └─ Chapter 34 - 2:03:30
│  └─ Tracks
│     ├─ ❎ Video - Mpeg4 AVC High@L4.1
│     ├─ ❎ Audio - DTS-HD Master Audio
│     ├─ ❎ Audio - DTS
│     ├─ ❎ Subtitles - HDMV PGS Subtitles
│     ├─ ❎ Subtitles - HDMV PGS Subtitles
│     └─ ❎ Attachment - image/jpeg
└─ ✅ The Good Place Season One: Disc One - 0:24:14, 6 chapter(s), 6.9 GB
   ├─ Chapters
   │  ├─ Chapter 01 - 0:00:00
   │  ├─ Chapter 02 - 0:01:45
   │  ├─ Chapter 03 - 0:07:30
   │  ├─ Chapter 04 - 0:14:59
   │  ├─ Chapter 05 - 0:20:39
   │  └─ Chapter 06 - 0:23:22
   └─ Tracks
      ├─ ✅ Video - Mpeg4 AVC High@L4.1
      ├─ ✅ Audio - DTS-HD Master Audio
      ├─ ✅ Audio - DTS
      ├─ ✅ Subtitles - HDMV PGS Subtitles
      ├─ ✅ Subtitles - HDMV PGS Subtitles
      └─ ✅ Attachment - image/jpeg


Saving selected titles...
/home/dex/Videos/The Good Place Season One- Disc One_t06.mkv: 100%|███████████████████████████▉| 65516/65536 [1:14:10<00:01, 14.72it/s, 7.6 M/s [1.7X] [SAFE]]
It's taken a few weeks of work, but it's in a state that I think can be released for feedback. I would appreciate any thoughts
mmkv_abi - a Python library for MakeMKV
flojo
Posts: 80
Joined: Thu Jun 22, 2023 4:27 am
Location: El Paso

Re: mmkv_abi: A Python library for MakeMKV

Post by flojo »

In regards to Blu-Ray:

The info really needs to come from within the JRE. Without makemkvcon's source, you should still be able to use the daemon filter to hack your way through it. I hope you do because the data within JRE is, I assume, much more trustworthy.

2 questions:
1. Which information is available via the GUI which isn't makemkvcon?
2. Can you control makemkvcon's SCSI with this? Being able to resume/retry a rip would be handy.

If/when I rip something again, I'll try your script. FWIW, I parsed the output of makemkvcon into JSON via this: viewtopic.php?f=10&t=32370 I didn't spend as long as you on it but, I feel it was pointless unless the data comes from within the JRE. The obfusticated playlist titles really throw a wrench in non-JRE methods. Of course, I'm _assuming_ there is definitive data in the JRE which aids in defeating the obfustication, but I really don't know :-/.
me_dex
Posts: 2
Joined: Tue Jan 16, 2024 3:39 am
Contact:

Re: mmkv_abi: A Python library for MakeMKV

Post by me_dex »

The obfusticated playlist titles really throw a wrench in non-JRE methods. Of course, I'm _assuming_ there is definitive data in the JRE which aids in defeating the obfustication, but I really don't know :-/.
The goal of this project is basically just to provide advanced scripting access to MakeMKV; allowing a more programmatic way to perform ripping of large collections based on heuristics of the collection (title duration, length, language selection, etc) and to allow building of alternative interfaces. It started as a project to provide access to MakeMKV via a web API. It's not really meant to do more detailed information extraction beyond the information that MakeMKV provides.
1. Which information is available via the GUI which isn't makemkvcon?
One example would be drive information. MakeMKV makes available, prior to title scanning, detailed information about the drives that it detected, LibreDrive information, and basic information about the disc inserted (name, protection, etc). This library parses that information pretty much the same way the GUI would.
2. Can you control makemkvcon's SCSI with this? Being able to resume/retry a rip would be handy.
Yes - the library is able to control makemkvcon's SCSI functionality like ejecting a disc. The helper function to do this (eg makemkv.eject_disc(0)) isn't written yet, but it should be added in a later release. It should also be able to detect when a rip has failed and allow for scripting of automatic retries.
mmkv_abi - a Python library for MakeMKV
jemima
Posts: 54
Joined: Fri Oct 06, 2023 1:16 am

Re: mmkv_abi: A Python library for MakeMKV

Post by jemima »

Really nice. That should be part of MakeMKV, so that one can be sure it's up2date. :-)

btw: I think you needlessly import pprint but never use it afterwards.


Cheers,
Jemima
Post Reply