Finding a valid DVD
I am currently working on a tool to play DVDs over the network. Technically, VLC already does that, but what I would like is something like Plex, but that can play movies from a selection, but from the files of a DVD so that I can access menus and extras.
What makes a valid DVD?
A valid DVD, in the real specifications, is basically an ISO-9660 file system that contains an AUDIO_TS directory, usually empty for we are talking about DVD-Video and not DVD-Audio, and a VIDEO_TS directory that contiguously contains VIDEO_TS.IFO along with its backup, VIDEO_TS.BUP, followed by a VOB video file for the menu, VIDEO_TS.VOB, then contains title sets, noted as an IFO VTS_xx_0.IFO with its backup VTS_xx_0.BUP and its VOB parts, VTS_xx_0.VOB up to VTS_xx_n.VOB where xx is the numerical identifier to the title set and n is the part of the current title set, understanding that xx starts at 01 because 00 is VIDEO_TS.VOB and n starts at 0, considering that VOB files are naught but MPEG-2 videos part of a subset of the MPEG-2 specifications where all VOB files are valid MPEG-2 videos but not all MPEG-2 videos are valid VOB files.
A valid DVD, as far as nethomevideo has to concern itself, is a directory that contains a VIDEO_TS directory that contains a valid VIDEO_TS.IFO file.
An IFO file is a long data structure that contains a plethora of fields that range from very useful for nethomevideo, such as the number of title sets on a DVD, to incredibly futile such as the Provider ID, which would be useful if distributors actually filled it out. The problem with IFO files is that pretty much all fields change meaning depending on whether it is a VMG or video manager IFO or a VTS or video title set IFO. For instance, at offset 0x00C4, you’ll find a sector pointer to the table of titles in VIDEO_TS.IFO which is a VMG IFO, but the start sector of the title VOB in a VTS IFO. The pointer to the table of titles and chapter in a VTS IFO is at 0x00C8, which is a sector pointer to the menu program chain in the VMG IFO.
The way you differentiate a VTS IFO from a VMG IFO is easy: look at the first 12 bytes. Any IFO file starts with DVDVIDEO-, and then three characters, either VMG or VTS.
What does nethomevideo check for?
As of now, all that nethomevideo does is verify that the directory you have given is actually a DVD and then load its number of title sets from the VMG IFO.
Beyond checking that the given directory to a DVD file is actually a directory that exists, it checks for a VIDEO_TS directory in the given path, otherwise it throws some lovely exceptions from the Standard Template Library. It then proceeds to check if a VMG IFO exists, otherwise it again throws some even lovelier exceptions from the Standard Template Library. Then it checks for an optional AUDIO_TS directory in the root of the DVD.
What I’ll have to implement next
I’d first like to move the logic that loads the IFO file to get the title set count of the DVD to a new function to load any type of IFO that would ideally return a struct containing all fields of the IFO along with the type of IFO. Field names change between VMG and VTS IFO files but their sizes and quantity stay the same lest they are straight up left blank and unused. My main goal for now is to get to actually writing an interpreter for the Interaction Machine, basically the DVD menu bytecode. It will probably run on the server-side using client-side inputs, which given it’ll run on LAN and not over WAN, tunnels or anything like that, lest it’s a demo, should probably be fine for latency. Although, given actual input latency on a real player, it’d probably be just like the real thing. After that, it’ll be a matter of putting all that logic inside of a reusable class that I can instanciate for any new movie session. If all goes to plan, at least.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.