How to obtain titles and chapters information in DVD?

Tarhan picture Tarhan · Sep 2, 2012 · Viewed 16.9k times · Source

I found many question about creating DVD menu using ffmpeg but i did not find any one about programmically access to DVD structure information. When i using libav (or FFmpeg) library i can open DVD image (iso file) and access to video, audio and subtitle streams. But i could not find any API.

I can play video and found information using VLC player (and so libvlc library). But I need to do some processing on audio and subtitle stream programmically. I don't want to split VOBs using tools like SmartRipper, and only then do processing.

Does libav(ffmpeg) contain any API for dealing with DVD menus? If not can you recommend any other library which can be used to obtain information about title(chapter) start and end time with one frame(sample, AVPacket) accuracy?

I heard about libdvdnav library but i don't know if it right for me. I'm new to libav and DVD format internals.

Answer

Nick picture Nick · Jan 6, 2018

I'm not sure about what 1-frame accuracy means in this context. However, I've been using a tool called lsdvd, which is a basic CLI tool that takes as it's only parameter, the block device of your DVD drive. (Without that parameter, it will guess /dev/dvd, which is lacking on modern Linux, and is usually /dev/sr0.) It will then give you a nice listing of the chapters on the disc, like so:

$ lsdvd /dev/sr0
Disc Title: METAL_DISC_2
Title: 01, Length: 00:00:00.433 Chapters: 01, Cells: 01, Audio streams: 01, Subpictures: 01
Title: 02, Length: 00:00:11.500 Chapters: 01, Cells: 01, Audio streams: 01, Subpictures: 00
Title: 03, Length: 00:00:00.433 Chapters: 01, Cells: 01, Audio streams: 01, Subpictures: 01
Title: 04, Length: 00:00:00.433 Chapters: 01, Cells: 01, Audio streams: 01, Subpictures: 01
Title: 05, Length: 00:00:09.000 Chapters: 01, Cells: 01, Audio streams: 01, Subpictures: 00
Title: 06, Length: 00:00:10.000 Chapters: 01, Cells: 01, Audio streams: 01, Subpictures: 00
Title: 07, Length: 00:00:00.433 Chapters: 01, Cells: 01, Audio streams: 01, Subpictures: 01
Title: 08, Length: 00:25:02.333 Chapters: 06, Cells: 06, Audio streams: 01, Subpictures: 00
Title: 09, Length: 00:00:00.433 Chapters: 01, Cells: 01, Audio streams: 01, Subpictures: 00
Title: 10, Length: 00:07:48.700 Chapters: 16, Cells: 16, Audio streams: 01, Subpictures: 00
Title: 11, Length: 00:00:00.433 Chapters: 01, Cells: 01, Audio streams: 01, Subpictures: 00
Title: 12, Length: 00:16:43.066 Chapters: 08, Cells: 08, Audio streams: 01, Subpictures: 00
...snip...
Longest track: 20

If you wish to write your own code, I imagine looking at the source for lsdvd will be instructive. The only library it links against in Fedora 25 (other than standard stuff) is libdvdread.so.4, which is part of the dvdnav project.

HTH.