Chapters inside MP4 file
Forum rules
*******************************
Please be aware we are now using GitHub for issue tracking and feature requests.
- This section of the forum is now closed to new topics.
*******************************
*******************************
Please be aware we are now using GitHub for issue tracking and feature requests.
- This section of the forum is now closed to new topics.
*******************************
Text subtitles are best left for another tool, methinks. Character recognition is a nightmare, to say the least.
Although a big thanks for the work to libmp4v2, as I do have a couple ideas on a Metadata tool for MP4 files where letting someone add chapter tracks and subtitles after the fact (in addition to tagging for iTunes) would be nice features.
EDIT: Nevermind, there is still work to be done to scratch my particular itch... but nothing really Earth-shattering. I can do the work pretty easily at this point to enhance it. I was hoping I could enter the chapter titles from my DVD insert, and have those inserted into the text track instead. I might work on it a bit tonight.
Although a big thanks for the work to libmp4v2, as I do have a couple ideas on a Metadata tool for MP4 files where letting someone add chapter tracks and subtitles after the fact (in addition to tagging for iTunes) would be nice features.
EDIT: Nevermind, there is still work to be done to scratch my particular itch... but nothing really Earth-shattering. I can do the work pretty easily at this point to enhance it. I was hoping I could enter the chapter titles from my DVD insert, and have those inserted into the text track instead. I might work on it a bit tonight.
Last edited by Cyander on Fri Mar 23, 2007 8:20 pm, edited 1 time in total.
Hi Cyander,
No worries! I agree about text subtitles - OCR is a biggie, especially given the subtitles could be in any number of languages...
Good call on the "applying chapters" tool. Rhester was asking me about this earlier on - I'm sure there are lots of Handbrake users who have many ripped DVDs without chapter markers, which they'd rather not rip again. Would be very useful, I'm sure.
I haven't really gone the whole hog with adding text tracks to libmp4v2 - that is, I don't actually use the "add text track" function I added, just the "add chapter text track" function. But it should work for basic text tracks, I think. Adding text track samples is then as easy as calling MP4WriteSample with a buffer where the first two bytes specify the length of the following text, followed by the text itself. If you want to do unicode, you'll need to add an extra 'encd' atom afterwards, I think. Here's some useful links on text samples:
http://developer.apple.com/documentatio ... H205-57434
http://lists.apple.com/archives/QuickTi ... 00147.html
- maurj.
No worries! I agree about text subtitles - OCR is a biggie, especially given the subtitles could be in any number of languages...
Good call on the "applying chapters" tool. Rhester was asking me about this earlier on - I'm sure there are lots of Handbrake users who have many ripped DVDs without chapter markers, which they'd rather not rip again. Would be very useful, I'm sure.
I haven't really gone the whole hog with adding text tracks to libmp4v2 - that is, I don't actually use the "add text track" function I added, just the "add chapter text track" function. But it should work for basic text tracks, I think. Adding text track samples is then as easy as calling MP4WriteSample with a buffer where the first two bytes specify the length of the following text, followed by the text itself. If you want to do unicode, you'll need to add an extra 'encd' atom afterwards, I think. Here's some useful links on text samples:
http://developer.apple.com/documentatio ... H205-57434
http://lists.apple.com/archives/QuickTi ... 00147.html
- maurj.
The only difference between a chapter track, and a text subtitle track is that the text atom and possibly the samples have text formatting data. Just that with a chapter track, you don't need it...maurj wrote: I haven't really gone the whole hog with adding text tracks to libmp4v2 - that is, I don't actually use the "add text track" function I added, just the "add chapter text track" function. But it should work for basic text tracks, I think. Adding text track samples is then as easy as calling MP4WriteSample with a buffer where the first two bytes specify the length of the following text, followed by the text itself. If you want to do unicode, you'll need to add an extra 'encd' atom afterwards, I think. Here's some useful links on text samples:
- maurj.
I hope you don't mind me jumping in here. Excellent work, it's quite exciting to have this working!
One minor issue is that with my (limited) testing, chapter marks are very slightly too early - about 10 frames I think, although I've not tried to pin it down exactly... Is this the same issue Metadata Hootenanny used to have with the ripped file being a slightly different length to the DVD?
One minor issue is that with my (limited) testing, chapter marks are very slightly too early - about 10 frames I think, although I've not tried to pin it down exactly... Is this the same issue Metadata Hootenanny used to have with the ripped file being a slightly different length to the DVD?
It isn't going to be as easy as I hoped to restore the sync. The problem is that the data is frame accurate /until/ it goes through the sync step. After that, the chapter breaks lose sync, because we have no good way to keep track of how the breaks are being adjusted.
I am looking into a couple ways to use the frame queues themselves to propogate these chapter breaks, so that when syncing/etc, these 'frames' will continue to be between the right two frames, making them good time markers.
EDIT: Okay, I am officially starting to be at a loss at how to fix this. The sync process for video and audio is pretty complex, and even though my results are turning out /pretty/ well, I simply cannot get the sync to turn out the way I expect. The problem tends to be that even when I attach a chapter 'tag' to individual frames as they are read from the DVD and decoded, something is just happening to make the chapter appear in the stream earlier than expected.
FURTHER: Oh man... I can't believe this is staring me right in the /face/. A pair of bugs in some older code which tries to calculate the chapter from the current 'cell' in the DVD is what seems to be preventing my sync method from working. I have fixed both bugs, and while I still need to validate with a full run of something full-length... it is working on small 3-4 chapter clips just fine. Best of all, it does appear to be frame-accurate.
I want to wrap up the support for better chapter titles (user-generated), and see if I can't get someone to check this in. It works swell.
I am looking into a couple ways to use the frame queues themselves to propogate these chapter breaks, so that when syncing/etc, these 'frames' will continue to be between the right two frames, making them good time markers.
EDIT: Okay, I am officially starting to be at a loss at how to fix this. The sync process for video and audio is pretty complex, and even though my results are turning out /pretty/ well, I simply cannot get the sync to turn out the way I expect. The problem tends to be that even when I attach a chapter 'tag' to individual frames as they are read from the DVD and decoded, something is just happening to make the chapter appear in the stream earlier than expected.
FURTHER: Oh man... I can't believe this is staring me right in the /face/. A pair of bugs in some older code which tries to calculate the chapter from the current 'cell' in the DVD is what seems to be preventing my sync method from working. I have fixed both bugs, and while I still need to validate with a full run of something full-length... it is working on small 3-4 chapter clips just fine. Best of all, it does appear to be frame-accurate.
I want to wrap up the support for better chapter titles (user-generated), and see if I can't get someone to check this in. It works swell.
Hehe, I hate it when that happens. Frame-accurate is better than I'd dared hope... I'll be very happy to give it a thorough testCyander wrote:FURTHER: Oh man... I can't believe this is staring me right in the /face/. A pair of bugs in some older code which tries to calculate the chapter from the current 'cell' in the DVD is what seems to be preventing my sync method from working. I have fixed both bugs, and while I still need to validate with a full run of something full-length... it is working on small 3-4 chapter clips just fine. Best of all, it does appear to be frame-accurate.
Nah... the bugs are in dvd.c. Ironically, fixing them has /zero/ effect on the behavior of the program. Very subtle stuff too.jbrjake wrote:In HB code? Where? You're not talking about sync.c, are you?Cyander wrote:A pair of bugs in some older code which tries to calculate the chapter from the current 'cell' in the DVD is what seems to be preventing my sync method from working.
EDIT: Okay, hopefully the last time I have to (heavily) work on this. I thought I had the sync issue, but then there were still some (more subtle) sync issues underneath. It turns out that most DVDs have a couple pictures from a group of pictures spilling over into the next chapter's section of the disc. DVD players skip these, and move onto the next group. So I had to do a little extra work to ensure that a chapter mark got 'delayed' by the MPEG-2 decoder until the next group of pictures arrived. I also did some work on the UI so you can set the chapter titles before ripping, and get something better than simply: Chapter 01, Chapter 02. Also cleaning up maurj's text sample writing code while I am at it.
Long story short, I have been getting frame-accurate sync on chapters (compared to actual DVD players) for all DVDs I have tried, and I can name the chapters something meaningful. I'll post a diff tomorrow when I have time to remove some 'stupid printfs I used because XCode blows at debugging static libs'.
Bump.
Okay, I think this thing is about ready to let the HB team look it over and decide if they want to accept/deny the patch. I ran about as close to a test suite as I can run on a Mac Pro with 2 drives, and in 8 hours. No more bugs/errors when compared to DVD Player or a standalone box.
I'll be opening up a new thread in the development forum once I am finished with the cleanup.
EDIT: BTW, I added UTF-8 support for the chapter titles when they come from the UI. Works well.
Okay, I think this thing is about ready to let the HB team look it over and decide if they want to accept/deny the patch. I ran about as close to a test suite as I can run on a Mac Pro with 2 drives, and in 8 hours. No more bugs/errors when compared to DVD Player or a standalone box.
I'll be opening up a new thread in the development forum once I am finished with the cleanup.
EDIT: BTW, I added UTF-8 support for the chapter titles when they come from the UI. Works well.
I'm having an issue with the latest SVN and chapter markers not being created. I'm ripping off of my X-Files Season 1 DVD, and while each title has a number of chapters on the disc, the chapters are not created in the resulting file. Anyone have any thoughts on what could be causing the problem, or if there are any related known issues?
I've made sure that the 'create chapter markers' box has been checked, both on the main window and in the preferences. Also, it does not seem to matter if I rip directly from the DVD or after moving the VOB files to the hard drive w/ MtR.
I've made sure that the 'create chapter markers' box has been checked, both on the main window and in the preferences. Also, it does not seem to matter if I rip directly from the DVD or after moving the VOB files to the hard drive w/ MtR.
Wow, that was it. Changed the extension from .mp4 to .m4v and it works fine. Now that you mention it, I do somewhat remember reading that in the IRC channel at one point. Thanks!dynaflash wrote:As I recall, maurj (who wrote that feature) said you need to use the .m4v file extension for iTunes to recognize the chapter markers.
Guys, you have no idea how excited I got reading this thread. I nearly soiled my panties. This is big, big, big. All the volunteers working on HB are awesome.
I have hundreds of instructional DVDs where the chapter marks are critically important, that's why I haven't ripped many of them to mp4 (nor m4v) yet. Most of the ones that I did rip were ripped to individual chapters, which is an incredibly tedious process involving dozens of mouse clicks and navigating pop-up menus and switching back and forth to the keyboard for every single chapter. I guess you guys already know that.
User editable chapter names would be gravy. I'll be so excited when I rip my first DVDs with chapter marks and see those chapters on my iPod.
Chapter marks will also come in handy for porno movies.
Hopefully, someday I'll be able to also add chapter marks to the mp4 files I created from my VHS tape captures. I know that's not an HB issue though.
I have hundreds of instructional DVDs where the chapter marks are critically important, that's why I haven't ripped many of them to mp4 (nor m4v) yet. Most of the ones that I did rip were ripped to individual chapters, which is an incredibly tedious process involving dozens of mouse clicks and navigating pop-up menus and switching back and forth to the keyboard for every single chapter. I guess you guys already know that.
User editable chapter names would be gravy. I'll be so excited when I rip my first DVDs with chapter marks and see those chapters on my iPod.
Chapter marks will also come in handy for porno movies.
Hopefully, someday I'll be able to also add chapter marks to the mp4 files I created from my VHS tape captures. I know that's not an HB issue though.
I have a build that does reliably let the user edit chapter marks (and the support for frame-accurate sync has improved from the diff I showed to the dev team). This will make it into HB, it is just a matter of timing, and that it is likely better for stability of 0.8.5b1 if it was submitted for b2.Neil wrote: User editable chapter names would be gravy. I'll be so excited when I rip my first DVDs with chapter marks and see those chapters on my iPod.
Well, the good news is that we now know how to make chapter tracks work for iTunes. It isn't a mystery anymore, which means other tools will be able to eventually incorporate the feature in the future.Hopefully, someday I'll be able to also add chapter marks to the mp4 files I created from my VHS tape captures. I know that's not an HB issue though.
Thanks
I downloaded 8.5.1 yesterday, and just wanted to take a moment to say thanks. I know that you guys must have put a lot of work into the new beta, and I'm extremely happy that you took the time to incorporate this feature.
Great work all of you, and keep it up!
Thanks again,
Vidar.
Great work all of you, and keep it up!
Thanks again,
Vidar.