2007-12-16, 20:12 | Link #1 |
Excessively jovial fellow
Join Date: Dec 2005
Location: ISDB-T
Age: 37
|
[Encoding Technobabble] Ordered Chapters And You - what, how, why, when
First off: MP4 fanatics get out, this does not apply to you. You can go play with your nonstandard chapters and small plastic hardware player toys all you want instead.
Some of you may have noticed people talking about this Matroska feature called "ordered chapters" like if it was the second coming of Christ or something. It's not, really, but it's pretty awesome in its own right and you can do pretty amazing things with it, like supplying both hardsubbed and softsubbed OP/ED's without having two versions of the entire file; encoding the OP/ED of an entire season just once and then seamlessly integrating it into every episode; or splitting full-length movies into CD-sized pieces while each part acts as if it was the whole movie. There's a lot more you can do, the virtual timeline stuff has some truly mind-boggling implications. The only real downside of this feature so far has been that there's approximately zero documentation on how to use it, unless you read the Matroska specification or have ready access to Haali himself. To help remedy this I wrote a rather lengthy guide on how to use the more obscure features and what you can do with them. That is all. Questions go in this thread or to #darkhold on IRC, not in my blog comments since noone including myself reads my blog. I expect to see at least one release using this feature in the upcoming season, so start reading. Chop chop, gentlemen! Edit: this post came off as a fair bit more self-centered than I intended it to be. This feature is not new (in fact it has been around almost since the creation of Haali's splitter in 2004 or so) and I'm far from the first one to figure it out. I'm just the first one to write anything extensive about it. Look mom, I'm famous on the internet!
__________________
Last edited by TheFluff; 2009-07-19 at 11:19. |
2007-12-16, 21:43 | Link #2 |
Senior Member
Join Date: Oct 2007
Location: Florida, USA
|
I cry tears of joy for you; I can finally slice off those damn 1:30 OPs and EDs of series that graze just past the 4.7GB mark after my custom XviD to h264 encodes and I can now select which one I like the best.
Many thanks, yet again. This is a great technique to (attempt to) master to learn how to compress entire series rips and their OPs and credits/EDs: Hollywood, Anime, Bollywood, and otherwise. DVD Rippers, take note. |
2007-12-17, 19:40 | Link #4 |
Two bit encoder
Fansubber
Join Date: Jan 2006
Location: Chesterfield, UK
Age: 39
|
Good to see you longposting. Not so good to see you trolling/taking pot shots.
Anyway, information is a great thing. Now go and teach the raw cappers not to suck, and the raw providers to spot shitty upscales and awarpsharp abuse. I like the idea of these chapters and how you can effectively remove so much redundancy. It's also good because when I've seen an Op once/twice, I generally don't want to see it again (unless it's very good). There's also the added bonus of having the Op/Ed seperately if you do happen to like them (I have a few that I extracted and encoded, such as Gundam X's Op). Oh that's something. In a series that has been linked to an external Op/Ed; what behaviour would you get if that Op/Ed didn't exist? Would it just play the episode regardless? That would be pretty handy if a series had an Op you didn't care for. Just leave those out of the batch torrent and watch each episode without having to skip/seek/go to chapter. Also this has no practical reasoning, just pure curiosity. I'm guessing the answer to these are yes, having some knowledge of how splitters and decoders work, but I'll ask anyway. What would happen if the Op/Ed were different framerates to the original episode (eg the episodes are 23.976 and the Op/Ed is 29.97) (lol poor mans VFR); would it still play? Also what if different resolutions or codec? (maybe for example you found a textless Op/Ed and replaced the original with those, but they were encoded slightly differently)? It probably depends on the player/codecs/splitter as much as anything, kind of like switching to different angles using different codecs maybe. Anyway, if nothing it might be something to test to see if you can get it to break anything decoder side, or maybe serve as another crazy test file for CCCP.
__________________
|
2007-12-17, 20:22 | Link #5 | ||||
Excessively jovial fellow
Join Date: Dec 2005
Location: ISDB-T
Age: 37
|
I learned from the best!
No post is truly complete without a touch of trolling to make it interesting. :V Quote:
Quote:
Quote:
(Reference for the following paragraphs: http://haali.cs.msu.ru/mkv/codecs.pdf) One interesting gotcha with this is that for S_TEXT/ASS and S_TEXT/SSA the entire script info and styles sections of the file is stored in the CodecPrivate header, so any style you want to involve in segment linking of any kind must exist in all the involved segments; the script headers need to be the same as well. I have not yet tested how far you can stretch this and still get away with working playback. For V_MS/VFW/FOURCC (pretty much anything muxed from AVI), the CodecPrivate is the BITMAPINFOHEADER of the AVI file (contains stuff like resolution and bits per pixel) followed by some codec-specific private data, so your mileage may vary with which settings you can change and which you can't. In some cases mkvmerge can exit with warnings but the resulting file plays anyway. For V_MPEG4/ISO/AVC (h.264) the CodecPrivate is a rather interesting structure that among other things stores the profile, the level, the SPS's and PPS's. For anything else, just read Haali's PDF or experiment. For the most part it has been pretty simple to get things working right in my tests. Quote:
__________________
Last edited by TheFluff; 2007-12-17 at 20:46. |
||||
2007-12-18, 14:12 | Link #6 |
Aegisub dev
Join Date: Sep 2004
Location: Stockholm, Sweden
Age: 39
|
One important note:
Two Vorbis streams, even encoded with the same encoder and same settings, might have different CodecPrivate headers, because it AFAIK stores the codebook, which is dynamic for Vorbis. At least that's something I think I noticed once when i tried concatenating two Vorbis streams in mmg.
__________________
|
2007-12-18, 16:24 | Link #7 | |
Excessively jovial fellow
Join Date: Dec 2005
Location: ISDB-T
Age: 37
|
Well after consulting the literature I must conclude that I may be behind my times by almost two years. Quoting the following mkvtoolnix changelog item from 2006-02-27:
Quote:
__________________
|
|
2007-12-20, 19:17 | Link #8 |
Excessively jovial fellow
Join Date: Dec 2005
Location: ISDB-T
Age: 37
|
Ugh, double post, but anyway, I created a sample that demonstrates some of what you can do with ordered chapters. Download here: http://uppcon.se/thefluff/samples/or...ters-sample.7z (30mb)
Edit: "cheat sheet", i.e. the XML files I used: http://uppcon.se/thefluff/samples/or...sample-xmls.7z
__________________
Last edited by TheFluff; 2007-12-24 at 01:12. |
2007-12-24, 15:54 | Link #9 |
Timer and Stuff
|
I was exporting the xml chapter files from Hitsuji's encodes of Suzumiya and looking at those to figure out ordered chapters along with mkvtoolnix's (sparse) documentation on UID's, but this makes things a whole lot easier! Especially some of the applications of it you suggest. Thanks Fluff, your awesome!
|
2008-01-01, 08:31 | Link #10 |
ForUs
|
Hey TheFluff, please help ;0
Im using ordered chapters to add an ending from a diffrent file. Original anime had already been writen in mkv with ordered chapters, so it was only the matter of changing the ChapterSegmentUID... or so I thought. The original part: Code:
<ChapterAtom> <ChapterUID>3611616</ChapterUID> <ChapterFlagHidden>0</ChapterFlagHidden> <ChapterFlagEnabled>1</ChapterFlagEnabled> <ChapterTimeStart>00:12:44.514000000</ChapterTimeStart> <ChapterTimeEnd>00:23:11.174000000</ChapterTimeEnd> <ChapterSegmentUID format="hex"> b8 7c 13 a0 3d 65 ee 07 82 53 d4 84 5f 4c a6 74 </ChapterSegmentUID> <ChapterDisplay> <ChapterString>Part B</ChapterString> <ChapterLanguage>und</ChapterLanguage> </ChapterDisplay> </ChapterAtom> <ChapterAtom> <ChapterUID>453616</ChapterUID> <ChapterFlagHidden>0</ChapterFlagHidden> <ChapterFlagEnabled>1</ChapterFlagEnabled> <ChapterTimeStart>00:23:11.174000000</ChapterTimeStart> <ChapterTimeEnd>00:24:15.963000000</ChapterTimeEnd> <ChapterSegmentUID format="hex"> b8 7c 13 a0 3d 65 ee 07 82 53 d4 84 5f 4c a6 74 </ChapterSegmentUID> <ChapterDisplay> <ChapterString>Ending Credits</ChapterString> <ChapterLanguage>und</ChapterLanguage> </ChapterDisplay> </ChapterAtom> <ChapterAtom> <ChapterUID>51546130566</ChapterUID> <ChapterFlagHidden>0</ChapterFlagHidden> <ChapterFlagEnabled>1</ChapterFlagEnabled> <ChapterTimeStart>00:24:32.619000000</ChapterTimeStart> <ChapterTimeEnd>00:24:48.936000000</ChapterTimeEnd> <ChapterSegmentUID format="hex"> b8 7c 13 a0 3d 65 ee 07 82 53 d4 84 5f 4c a6 74 </ChapterSegmentUID> <ChapterDisplay> <ChapterString>Next Episode Preview</ChapterString> <ChapterLanguage>und</ChapterLanguage> </ChapterDisplay> </ChapterAtom> Code:
<ChapterAtom> <ChapterUID>3611616</ChapterUID> <ChapterFlagHidden>0</ChapterFlagHidden> <ChapterFlagEnabled>1</ChapterFlagEnabled> <ChapterTimeStart>00:12:44.514000000</ChapterTimeStart> <ChapterTimeEnd>00:23:11.174000000</ChapterTimeEnd> <ChapterSegmentUID format="hex"> b8 7c 13 a0 3d 65 ee 07 82 53 d4 84 5f 4c a6 74 </ChapterSegmentUID> <ChapterDisplay> <ChapterString>Part B</ChapterString> <ChapterLanguage>und</ChapterLanguage> </ChapterDisplay> </ChapterAtom> <ChapterAtom> <ChapterUID>453616</ChapterUID> <ChapterFlagHidden>0</ChapterFlagHidden> <ChapterFlagEnabled>1</ChapterFlagEnabled> <ChapterTimeStart>00:00:00.000000000</ChapterTimeStart> <ChapterTimeEnd>00:01:04.531000000</ChapterTimeEnd> <ChapterSegmentUID format="hex"> 80 83 73 28 8b ea 1f 5d ab 7d ed 98 97 4f ca 87 </ChapterSegmentUID> <ChapterDisplay> <ChapterString>Ending Credits</ChapterString> <ChapterLanguage>und</ChapterLanguage> </ChapterDisplay> </ChapterAtom> <ChapterAtom> <ChapterUID>51546130566</ChapterUID> <ChapterFlagHidden>0</ChapterFlagHidden> <ChapterFlagEnabled>1</ChapterFlagEnabled> <ChapterTimeStart>00:24:32.619000000</ChapterTimeStart> <ChapterTimeEnd>00:24:48.936000000</ChapterTimeEnd> <ChapterSegmentUID format="hex"> b8 7c 13 a0 3d 65 ee 07 82 53 d4 84 5f 4c a6 74 </ChapterSegmentUID> <ChapterDisplay> <ChapterString>Next Episode Preview</ChapterString> <ChapterLanguage>und</ChapterLanguage> </ChapterDisplay> </ChapterAtom> It works as intended, but there are about 10mins of "empty space" on timeline, between the ending credits and next episode preview. When played, from beginning, the video player simply skips that space, but when I move playhead there, it eather crashes or only shows last rendered frame. I've read your "rather lengthy guide" and found "...remember that all ChapterTimeStart/End’s refer to timestamps of the underlying segment...", would that have something to do with my problem? Im not really sure what to do with it - I've loaded timecodes into aegisub, but dont know what to do next with it.
__________________
Last edited by 4as; 2008-01-07 at 10:14. |
2008-01-06, 20:59 | Link #11 |
Excessively jovial fellow
Join Date: Dec 2005
Location: ISDB-T
Age: 37
|
Sorry for being late with the response, I've been gone over the holidays.
Anyway, that looks correct to me (at a glance, at least). How did you remux it? With GDSmux? Remember that mkvmerge always changes the SUID when remuxing so if you remuxed the original file with it, the SUID pointing at that will now be invalid.
__________________
|
2008-01-06, 21:48 | Link #12 |
ForUs
|
With mkvmerge, and yes it changed SUID. But as I understand, if it was wrong, the ending would not show at all, but it plays fine.
Also I did some "research"; it seems that if I move the file (mkv with ending) to another folder, it obviously doesnt find it, and the gap (along with the ending) is gone. So something may be wrong with the ending, but no matter how I look it is 1min long, without any 10+ mins gap :S
__________________
|
2008-01-07, 10:13 | Link #14 | |
ForUs
|
Quote:
Just to be sure, I remuxed it again, and yeah, the gap is still there. Im in dead end here ._. I have no idea whats wrong... EDIT: This got me thinking, so I tried and changed the ChapterTimeEnd to simple 00:00:04.000000000. I presume ending should run now only for 4seconds, but surprisingly enough, it still played the whole thing… it is like ChapterTimeEnd doesn’t do anything o_O;
__________________
Last edited by 4as; 2008-01-07 at 11:11. |
|
2008-01-07, 11:35 | Link #15 |
Excessively jovial fellow
Join Date: Dec 2005
Location: ISDB-T
Age: 37
|
You're obviously doing it wrong SOMEWHERE but I can't figure out exactly what it is. I'm not sure what exactly you're trying to do either; what exactly is the file you're remuxing to going to contain and what is going to be linked in from other files?
__________________
|
2008-01-07, 12:36 | Link #16 |
Junior Member
Join Date: Jul 2007
|
I think I've managed to reproduce the problem. Make absolutely sure every ChapterUID is unique. It seems if two chapters have identical IDs, it simply takes the time of the longest of the two and assigns it to the first to appear (the remaining time is filled with blackness). The second chapter is dropped. Check the chapter menu to see which is missing; that would be the one with the duplicate UID (Note that, for instance, 0114 and 114 are considered the same UID.)
|
2008-01-07, 19:08 | Link #17 | |
ForUs
|
Quote:
YOU KNOW WHAT?! ... IT WORKED Instead of those random numbers like 10130428 and 30130428; I putted, for first 6 chapters, numbers from 1 to 6… and it worked! Seems like original file had wrong UIDs, as I didnt touch them. Anyway, Phar, your a life savior! Thank You Thank You Thank You. Also, thank you TheFluff. It is great to see there there are still peaople willing to help. PS: Original UIDs looked pretty unique to me (and no chapter was missing in chapter menu)… I cant think of nothing else then those UIDs where TOO complicated, seeing how simpler ones fixed the problem :S
__________________
|
|
2008-01-07, 19:53 | Link #18 |
King of Hosers
Join Date: Dec 2005
Age: 41
|
It's always the UIDs... never would have looked at the chapter ones though .
/me shakes fist and lols that encoders have taken over chat so ScR3WiEuS has nothing to say! Here is an extra tidbit TheFluff hasn't updated to his page yet. Simple windows script from Haali to grab the segment UIDs of files you are linking to, useful if you are remuxing lots and hate re-writing those segment uid's everytime. You run it as Code:
cscript //nologo path\to\updateseg.js \path\to\chapters.xml \path\to\updated_chapters.xml |
2009-06-05, 11:04 | Link #19 |
Senior Member
Join Date: Jun 2007
|
Pardon me for reviving an old discussion, but I've just tried ordered chapters after reading this. I have to say I'm impressed.
I want to ask one thing: I can see that the individual tracks in an MKV also have their own track UIDs, is it possible to create an Edition that takes video from one time period and play it with the audio from a different time period? For example, texted vs textless OPs and EDs. Even with ordered chapters to select the proper segments, I'll still have to include the audio for those twice. But if it's possible to assemble a "virtual segment" I can just instruct it to take the alternate video, but continue playing the default audio. So, is this possible? |
|
|