AnimeSuki Forums

Register Forum Rules FAQ Members List Social Groups Search Today's Posts Mark Forums Read

Go Back   AnimeSuki Forum > Anime Related Topics > Fansub Groups

Notices

Reply
 
Thread Tools
Old 2007-12-16, 20:12   Link #1
TheFluff
Excessively jovial fellow
 
 
Join Date: Dec 2005
Location: ISDB-T
Age: 28
[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!
__________________
| ffmpegsource
17:43:13 <~deculture> Also, TheFluff, you are so fucking slowpoke.jpg that people think we dropped the DVD's.
17:43:16 <~deculture> nice job, fag!

01:04:41 < Plorkyeran> it was annoying to typeset so it should be annoying to read

Last edited by TheFluff; 2009-07-19 at 11:19.
TheFluff is offline   Reply With Quote
Old 2007-12-16, 21:43   Link #2
Eviltape
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.
Eviltape is offline   Reply With Quote
Old 2007-12-16, 22:39   Link #3
Nicholi
King of Hosers
 
Join Date: Dec 2005
Age: 31
TheFluff has stolen my sekrats!!! SEKRATS!!!
Nicholi is offline   Reply With Quote
Old 2007-12-17, 19:40   Link #4
Zero1
Two bit encoder
*Fansubber
 
 
Join Date: Jan 2006
Location: Chesterfield, UK
Age: 30
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.
__________________
Zero1 is offline   Reply With Quote
Old 2007-12-17, 20:22   Link #5
TheFluff
Excessively jovial fellow
 
 
Join Date: Dec 2005
Location: ISDB-T
Age: 28
Quote:
Originally Posted by Zero1 View Post
Good to see you longposting.
I learned from the best!

Quote:
Originally Posted by Zero1 View Post
Not so good to see you trolling/taking pot shots.
No post is truly complete without a touch of trolling to make it interesting. :V

Quote:
Originally Posted by Zero1 View Post
Now go and teach the raw cappers not to suck, and the raw providers to spot shitty upscales and awarpsharp abuse.
I'd have to learn to write technobabble in Japanese first, so maybe in 10 years or so (given how long it took me to get where I am with English) but even then I'm afraid it's a lost cause...

Quote:
Originally Posted by Zero1 View Post
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.
Yes, that's what happens if you use Haali's splitter. If it can't find a segment, that part of the timeline is just skipped as if it didn't exist.

Quote:
Originally Posted by Zero1 View Post
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)?
All linked segments must have the same set of tracks with the same set of codecs; additionally the CodecPrivate header (and some other parameters) must be (mostly?) the same. Internally ordered chapters are just implemented with seeking so to avoid confusing the playback environment a lot you can't switch things like codecs, resolutions, samplerates or number of channels mid-playback. Different framerates and different display AR's work fine though.

(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:
Originally Posted by Zero1 View Post
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.
One of these days I'll prepare some samples, both for testing and for getting people to understand how awesome these features really are. :V
__________________
| ffmpegsource
17:43:13 <~deculture> Also, TheFluff, you are so fucking slowpoke.jpg that people think we dropped the DVD's.
17:43:16 <~deculture> nice job, fag!

01:04:41 < Plorkyeran> it was annoying to typeset so it should be annoying to read

Last edited by TheFluff; 2007-12-17 at 20:46.
TheFluff is offline   Reply With Quote
Old 2007-12-18, 14:12   Link #6
jfs
Aegisub dev
 
 
Join Date: Sep 2004
Location: Stockholm, Sweden
Age: 30
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.
__________________

Aegisub developer [ Forum | Manual | Feature requests | Bug reports | IRC ]
Don't ask for: More VSFilter changes (I won't), karaoke effects, help in PM's
jfs is offline   Reply With Quote
Old 2007-12-18, 16:24   Link #7
TheFluff
Excessively jovial fellow
 
 
Join Date: Dec 2005
Location: ISDB-T
Age: 28
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:
Originally Posted by mkvtoolnix changelog
* mkvmerge: enhancement: mkvmerge will no longer refuse to concatenate files with differing Codec Private contents and only issue a warning in such cases.
That's concatenation though and not linking, your mileage may still vary.
__________________
| ffmpegsource
17:43:13 <~deculture> Also, TheFluff, you are so fucking slowpoke.jpg that people think we dropped the DVD's.
17:43:16 <~deculture> nice job, fag!

01:04:41 < Plorkyeran> it was annoying to typeset so it should be annoying to read
TheFluff is offline   Reply With Quote
Old 2007-12-20, 19:17   Link #8
TheFluff
Excessively jovial fellow
 
 
Join Date: Dec 2005
Location: ISDB-T
Age: 28
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
__________________
| ffmpegsource
17:43:13 <~deculture> Also, TheFluff, you are so fucking slowpoke.jpg that people think we dropped the DVD's.
17:43:16 <~deculture> nice job, fag!

01:04:41 < Plorkyeran> it was annoying to typeset so it should be annoying to read

Last edited by TheFluff; 2007-12-24 at 01:12.
TheFluff is offline   Reply With Quote
Old 2007-12-24, 15:54   Link #9
Jubalint
Timer and Stuff
 
 
Join Date: Oct 2006
Location: Meh, who cares?
Send a message via AIM to Jubalint Send a message via Yahoo to Jubalint
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!
Jubalint is offline   Reply With Quote
Old 2008-01-01, 08:31   Link #10
4as
ForUs
 
 
Join Date: Sep 2006
Location: Poland
Age: 29
Send a message via MSN to 4as
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>
And my change:
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>
I figured out the ChapterTimeEnd by looking at "Duration" from the mkvinfo.

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.
4as is offline   Reply With Quote
Old 2008-01-06, 20:59   Link #11
TheFluff
Excessively jovial fellow
 
 
Join Date: Dec 2005
Location: ISDB-T
Age: 28
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.
__________________
| ffmpegsource
17:43:13 <~deculture> Also, TheFluff, you are so fucking slowpoke.jpg that people think we dropped the DVD's.
17:43:16 <~deculture> nice job, fag!

01:04:41 < Plorkyeran> it was annoying to typeset so it should be annoying to read
TheFluff is offline   Reply With Quote
Old 2008-01-06, 21:48   Link #12
4as
ForUs
 
 
Join Date: Sep 2006
Location: Poland
Age: 29
Send a message via MSN to 4as
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
4as is offline   Reply With Quote
Old 2008-01-07, 08:11   Link #13
Phar
Junior Member
 
Join Date: Jul 2007
You made a notation error:

<ChapterTimeEnd>0:01:04.531000000</ChapterTimeEnd>

Should be

<ChapterTimeEnd>00:01:04.531000000</ChapterTimeEnd>

I figure the splitter just reads the numbers and ignores the colons, so it was reading 00:10:45.
Phar is offline   Reply With Quote
Old 2008-01-07, 10:13   Link #14
4as
ForUs
 
 
Join Date: Sep 2006
Location: Poland
Age: 29
Send a message via MSN to 4as
Quote:
Originally Posted by Phar View Post
You made a notation error:

<ChapterTimeEnd>0:01:04.531000000</ChapterTimeEnd>

Should be

<ChapterTimeEnd>00:01:04.531000000</ChapterTimeEnd>

I figure the splitter just reads the numbers and ignores the colons, so it was reading 00:10:45.
Hmmm... I dont know how it got there, but in my actual code it is correctly written as “00" (probably deleted it while adding the bold tag).
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.
4as is offline   Reply With Quote
Old 2008-01-07, 11:35   Link #15
TheFluff
Excessively jovial fellow
 
 
Join Date: Dec 2005
Location: ISDB-T
Age: 28
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?
__________________
| ffmpegsource
17:43:13 <~deculture> Also, TheFluff, you are so fucking slowpoke.jpg that people think we dropped the DVD's.
17:43:16 <~deculture> nice job, fag!

01:04:41 < Plorkyeran> it was annoying to typeset so it should be annoying to read
TheFluff is offline   Reply With Quote
Old 2008-01-07, 12:36   Link #16
Phar
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.)
Phar is offline   Reply With Quote
Old 2008-01-07, 19:08   Link #17
4as
ForUs
 
 
Join Date: Sep 2006
Location: Poland
Age: 29
Send a message via MSN to 4as
Quote:
Originally Posted by Phar View Post
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.)
You know what?
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
4as is offline   Reply With Quote
Old 2008-01-07, 19:53   Link #18
Nicholi
King of Hosers
 
Join Date: Dec 2005
Age: 31
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
In the chapters file you write in @@path\to\file.mkv@@ for ChapterSegmentUID. If you can't run the script it just means you need to update Windows Script Host.
Nicholi is offline   Reply With Quote
Old 2009-06-05, 11:04   Link #19
Jimmy C
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?
Jimmy C is offline   Reply With Quote
Old 2009-06-05, 14:54   Link #20
TheFluff
Excessively jovial fellow
 
 
Join Date: Dec 2005
Location: ISDB-T
Age: 28
No, unfortunately not. You can only grab the entire timeline (video, audio, subtitles) at once; you cannot pick and choose what tracks you want to grab.
__________________
| ffmpegsource
17:43:13 <~deculture> Also, TheFluff, you are so fucking slowpoke.jpg that people think we dropped the DVD's.
17:43:16 <~deculture> nice job, fag!

01:04:41 < Plorkyeran> it was annoying to typeset so it should be annoying to read
TheFluff is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 14:53.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
We use Silk.