Multiple videos in a Matroska MKV container with Ordered Chapters / Segment Linking?

  Thread Rating:
  • 4 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
Zodler Offline
Senior Member
Posts: 125
Joined: Apr 2010
Reputation: 0
Post: #31
Actually no that is not the case. It doesn't just play one version. I had a file that when I played with XBMC, it played both versions combined and had a long running time, so it was unwatchable.

They should also consider this not only for MKVs but also for the main movie of the bluray structures that have 2 versions of the same movie.
find quote
hikaricore Offline
Posting Freak
Posts: 1,515
Joined: Dec 2008
Reputation: 0
Location: Tuesday
Post: #32
This will sadly be one of those things that drags out for a long time due to the slow development of ffmpeg.
Patches to support this feature have been available for about a year and a half and are being all but ignored by the devs.

[Image: output.jpg]
find quote
BLKMGK Offline
Donor
Posts: 1,738
Joined: Jul 2006
Reputation: 4
Location: USA Virginia
Post: #33
hikaricore Wrote:This will sadly be one of those things that drags out for a long time due to the slow development of ffmpeg.
Patches to support this feature have been available for about a year and a half and are being all but ignored by the devs.

Okay, so I brought this up many many moons ago and today got to searching about it again just to see if things had changed. I found Xin1Generator by accident and was quite surprised and happy about it and came here hoping to tell folks - only to find it was already mentioned. Yay!

As it stands now having two copies of a video in a container SUCKS and doing it with branches is a much smarter method ala BluRay. Since HD video can be so big this just makes common sense and is how they cram multiple versions of movies onto a piece of media. I have now ripped tons of movies that do this and it's ALWAYS a challenge deciding which version I want or keeping multiples which eat disk space like mad.

So - it's obviously a good idea and that brings us to ffmpeg. So now I am to understand this is the hang up and that we're stuck because they haven't accepted patches? Well, do these patches that have been proposed WORK? In the past the XBMC devs have been willing to accept patches out of the mainstream when they have been proven to be beneficial. One need only look at CABAC to see this! XBMC was able to use multiple cores to decode H.264 while the ffmpeg devs were squabbling about why it wasn't pretty or somesuch and I for one who was playing HIGH bitrate video sure appreciated it. This was pre-VDPAU BTW which was also something the XBMC devs jumped on pretty quickly.

Anyway, I think a case can be made that these types of files are smart to use. The hang up in the past has always been that no one seemed to know HOW to make such a file. Hopefully with Xin1Generator this will no longer be the case. I will be trying this tonight as I've been trying to figure out how the heck to do it for ages. IF this could be hooked up with eac3to it would ROCK! It would be sick to be able to use eac3to and this to have a single MKV capable of carrying all versions of a film. Then if there was a menu to select which version things would be even better - Matroska supports menus too....

Openelec Gotham, MCE remote(s), Intel i3 NUC, DVDs fed from unRAID cataloged by DVD Profiler. HD-DVD encoded with Handbrake to x.264. Yamaha receiver(s)
find quote
BLKMGK Offline
Donor
Posts: 1,738
Joined: Jul 2006
Reputation: 4
Location: USA Virginia
Thumbs Up  Playing with Xin1
Post: #34
Okay, I've chatted some with the developer of this program and he's explained a bit about it and I've begun tinkering. Instead of extracting multiple video files this program allows me to simply demux the video and audio separately. I've playing around with a BluRay of Bladerunner that has three cuts on it. After demuxing\extracting to VC-1 I have a video file that's 20gigs. If I were to extract EACH of those three movies I would have close to triple this size file - that's sick. To be able to do this as one file is much smarter IMO!

I have asked the developer what he is using to play back files as surely he must have some method. My fingers are crossed that this is something I can test with myself and I'll see if I can't find some more source materials to play with as well. Meanwhile I'm going to transcode this VC-1 file to x.264 and mux it with the files that his program has created and see what I can make of it.

I really do think that this, like CABAC previously and VDPAU, could be a very important feature for XBMC if it could be integrated well now that tools to create these files are appearing. Okay A tool but still! Previously I could hardly find any information on how to even approach building a file much less a danged tool No

Openelec Gotham, MCE remote(s), Intel i3 NUC, DVDs fed from unRAID cataloged by DVD Profiler. HD-DVD encoded with Handbrake to x.264. Yamaha receiver(s)
find quote
robpdotcom Offline
Junior Member
Posts: 7
Joined: Jan 2011
Reputation: 0
Post: #35
Playing multiple edition mkv's (and selecting different versions) shouldn't be a problem in XBMC. I've been doing it for months with MPC-HC, which if I remember correctly (haven't used XBMC in a while) can be used as the player in XBMC. I imagine that dsplayer would work as well.

The main requirement is that you MUST use Haali, since no other splitter supports ordered chapters in mkv. Once the file is loaded, you can select the versions of the film you want by right clicking on the Haali icon in the system tray.
find quote
BurningSky Offline
Senior Member
Posts: 197
Joined: Aug 2009
Reputation: 10
Location: Germany
Post: #36
But that doesn't work with XBMCLive etc. Wink
find quote
BLKMGK Offline
Donor
Posts: 1,738
Joined: Jul 2006
Reputation: 4
Location: USA Virginia
Post: #37
Okay, almost have a file I can test with - transcoding done last night. When I first began researching this some time ago I could find little documentation on it and it seemed like some complex feature of Matroska. However now that someone has written a tool that simplifies things I better understand what's going on I think. I'm also not convinced that ffmpeg needs tweaking to support this.

What the Xin1 tool appears to do is analyze the BD structure and create a couple of key files. These files do (at least) two important things. The first is figure out the various branches and create a chapter file that encompasses the various paths. The second thing it does is ensure that you have a file to be used during the x.264 encoding to insert key frames at the transition points so that the scene change is seamless. The downside here is that you lose normal chapter functionality - no biggie IMO.

Now, XBMC already supports chapters just fine. So it seems to be, no expert mind you, that base functionality to support this exists at some level. What's missing, I think, is the ability to choose which chapter path to follow and an interface to display those paths when available. Does this make sense to everyone? Seem feasible?

Now maybe Matroska does have something more tricky to support this but right now what the Xin1 developer seems to have built certainly seems to give the functionality desired and his tool processes the video to find the correct points to create the files pretty easily. I can report that the three copies of Blade Runner I compressed last night, total, used 20Gigs of space and just 12 once transcoded. That covers 3 full versions of the film which I am quite sure would've been close to 30gig had I done it the way I normally do with three copies! So yeah, efficiency gained for sure.

Playback is the issue and yeah right clicking Haali etc. won't fly for us since many of us are on Linux running things with a remote control. the developer did share with me that the mplayer-uau fork is capable of playing these files although I have not yet tried myself. I seem to recall that XBMC no longer uses mplayer and instead has it's own engine but perhaps code from this could be borrowed or at least looked at for ideas? I'm assuming of course that this is of interest to more than just a small number of us, maybe others don't care about multiple versions of movies. <shrug>

So, thoughts?

http://forum.xbmc.org/showthread.php?tid=41306 FWIW another thread on this. Also, thinking about this more maybe ffmpeg DOES need to support this. I seem to recall that mplayer had it's own renderer and so yeah now we use ffmpeg. D'oh! So can we accept some non-core branches to get support like was done with CABAC? Pretty please? Wink

Openelec Gotham, MCE remote(s), Intel i3 NUC, DVDs fed from unRAID cataloged by DVD Profiler. HD-DVD encoded with Handbrake to x.264. Yamaha receiver(s)
(This post was last modified: 2011-01-12 21:08 by BLKMGK.)
find quote
robpdotcom Offline
Junior Member
Posts: 7
Joined: Jan 2011
Reputation: 0
Post: #38
One good thing about the way xin1 creates the mkv is that if you play one of these "branching" mkv's on a player that does not support ordered chapters, it will simply play the first version of the movie, followed by the extra scenes which make up the other editions. So, you will still have a watchable movie, you will just be limited to watching the first version you selected when you set everything up.

And with a little extra work, you can have functioning chapters. All I do is load the chapter file into mkvmerge, and hide some of the chapters which are close together - this way, you won't have chapters which are only 1-2 minutes long. The chapters are still there, but they will not be selectable when watching the movie. It's also possible, though a bit more complicated and time consuming, to recreate the original chapter marks. It involves adding additional chapters, based on the original chapters and compensating for the extra content, and selectively hiding the appropriate, unneeded chapters. I've done it myself once, but it just isn't worth the time and effort imo. Hopefully, one day, this will also be done automatically by xin1.
find quote
BLKMGK Offline
Donor
Posts: 1,738
Joined: Jul 2006
Reputation: 4
Location: USA Virginia
Question   
Post: #39
robpdotcom Wrote:One good thing about the way xin1 creates the mkv is that if you play one of these "branching" mkv's on a player that does not support ordered chapters, it will simply play the first version of the movie, followed by the extra scenes which make up the other editions. So, you will still have a watchable movie, you will just be limited to watching the first version you selected when you set everything up.

I have noticed this - it's awesome! I think I will be doing movies like this and just using the main scene until XBMC supports this feature Smile

robpdotcom Wrote:And with a little extra work, you can have functioning chapters. All I do is load the chapter file into mkvmerge, and hide some of the chapters which are close together - this way, you won't have chapters which are only 1-2 minutes long. The chapters are still there, but they will not be selectable when watching the movie. It's also possible, though a bit more complicated and time consuming, to recreate the original chapter marks. It involves adding additional chapters, based on the original chapters and compensating for the extra content, and selectively hiding the appropriate, unneeded chapters. I've done it myself once, but it just isn't worth the time and effort imo. Hopefully, one day, this will also be done automatically by xin1.

Okay, can you please provide an example of how this is done? I'm ripping a BD tonight and would LOVE to be able to do this!! I've been emailing back and forth with the Xin1 developer, he's very responsive and approachable and if this isn't hard to do he might be willing. If I can provide an example it would be most helpful. He already uses eac3to so it would likely be just some extra processing and work on the XML chapter file.

Openelec Gotham, MCE remote(s), Intel i3 NUC, DVDs fed from unRAID cataloged by DVD Profiler. HD-DVD encoded with Handbrake to x.264. Yamaha receiver(s)
find quote
robpdotcom Offline
Junior Member
Posts: 7
Joined: Jan 2011
Reputation: 0
Post: #40
Quote:Okay, can you please provide an example of how this is done? I'm ripping a BD tonight and would LOVE to be able to do this!! I've been emailing back and forth with the Xin1 developer, he's very responsive and approachable and if this isn't hard to do he might be willing. If I can provide an example it would be most helpful. He already uses eac3to so it would likely be just some extra processing and work on the XML chapter file.


For the first edition, it's simple: Load the original chapters from the movie into mkvmergeGUI, and turn them into ordered chapters: each chapter just needs to have an ending time, which is the same as the start time for the next chapter (the end of chapter 1 is the beginning of chapter 2, etc). The ending of the last chapter is taken from the chapter list xin1 creates. Then you open the edited chapter list in notepad, and copy/paste it into the list xin1 created. In fact, everything necessary to create the chapters for the first edition can be accomplished by copy/paste.

The other editions are a bit complicated, because parts of the file are skipped, and you must account for that time and add it to the chapter time from the original chapter list. For example:

Suppose the first chapter in the original movie is at 8:00, but the first 2 chapters xin1 created are 0:00 to 5:00, and 7:00 to 12:00. You would need to create a chapter mark at 10:00 (which will show as being at 8:00 while you are watching the movie, because it is skipping past the 2 minutes between 5:00 and 7:00). Then, would split the second xin1 chapter into 2 chapters > 7:00-12:00 becomes 7:00-10:00, and 10:00-12:00. So now you have 3 chapters: 0:00-5:00, 7:00-10:00, and 10:00-12:00. Hide the first two chapters, and you will only see the third chapter (@ 10:00, which, again, will be seen as 8:00 when watching the movie). Confused

I don't know how much sense all of that makes, so some time early next week (I'll be out of town this weekend) I'll create some example xml files from a movie: the oringinal chapter lists, the xin1 created list, and the edited list. All the information needed is in the original list and the xin1 list, so it's definitely possible to be done automatically.

BTW: I was also trying to contact the developer, but haven't been able to find a way. I'd like to share some of the results I've gotten (I have found at least one movie that didn't work so well), and I'd like to make one feature request: an option to pick specific streams to be demuxed instead of writing a command to demux all the streams. It's easy to do that manually, but it would be a lot quicker if xin1 could do it for you.
find quote
BLKMGK Offline
Donor
Posts: 1,738
Joined: Jul 2006
Reputation: 4
Location: USA Virginia
Post: #41
robpdotcom Wrote:For the first edition, it's simple: Load the original chapters from the movie into mkvmergeGUI, and turn them into ordered chapters: each chapter just needs to have an ending time, which is the same as the start time for the next chapter (the end of chapter 1 is the beginning of chapter 2, etc). The ending of the last chapter is taken from the chapter list xin1 creates. Then you open the edited chapter list in notepad, and copy/paste it into the list xin1 created. In fact, everything necessary to create the chapters for the first edition can be accomplished by copy/paste.

The other editions are a bit complicated, because parts of the file are skipped, and you must account for that time and add it to the chapter time from the original chapter list. For example:

Suppose the first chapter in the original movie is at 8:00, but the first 2 chapters xin1 created are 0:00 to 5:00, and 7:00 to 12:00. You would need to create a chapter mark at 10:00 (which will show as being at 8:00 while you are watching the movie, because it is skipping past the 2 minutes between 5:00 and 7:00). Then, would split the second xin1 chapter into 2 chapters > 7:00-12:00 becomes 7:00-10:00, and 10:00-12:00. So now you have 3 chapters: 0:00-5:00, 7:00-10:00, and 10:00-12:00. Hide the first two chapters, and you will only see the third chapter (@ 10:00, which, again, will be seen as 8:00 when watching the movie). Confused

I don't know how much sense all of that makes, so some time early next week (I'll be out of town this weekend) I'll create some example xml files from a movie: the oringinal chapter lists, the xin1 created list, and the edited list. All the information needed is in the original list and the xin1 list, so it's definitely possible to be done automatically.

BTW: I was also trying to contact the developer, but haven't been able to find a way. I'd like to share some of the results I've gotten (I have found at least one movie that didn't work so well), and I'd like to make one feature request: an option to pick specific streams to be demuxed instead of writing a command to demux all the streams. It's easy to do that manually, but it would be a lot quicker if xin1 could do it for you.

Heh, yeah that makes my head spin but I think I see the potential! I will PM you the email of the Developer so that you can get a dialog going as well as he seems receptive to helpful suggestions and has also pondered trying to keep normal chapters - makes his head spin too I think Rofl

Playback is still a problem however. Any thoughts on convincing ffmpeg (ha) or thoughts on getting a modded ffmpeg into XBMC? I've mentioned it before but CABAC was also something the ffmpeg guys seemed to hate that XBMC picked up before it was in main trunk so it can certainly be done. Heck I'd self-compile ffmpeg to get this but without an interface in XBMC that doesn't help. Sad

Openelec Gotham, MCE remote(s), Intel i3 NUC, DVDs fed from unRAID cataloged by DVD Profiler. HD-DVD encoded with Handbrake to x.264. Yamaha receiver(s)
find quote
hikaricore Offline
Posting Freak
Posts: 1,515
Joined: Dec 2008
Reputation: 0
Location: Tuesday
Post: #42
The thing I don't get is that since xbmc already supports multiple audio tracks including (if I'm not mistaken) EXTERNAL audio tracks that aren't part of the original file, why would support for video tracks be that much more difficult? The ffmpeg argument seems like a cheap copout especially considering as you've said they've used unofficial patches in the past to achieve support for things people requested. The usage of ordered chapters is becoming more and more common and as it stands people either have to watch things in a way they weren't intended to be watched or use an external player for half their collection which seems to miss the point of a unified media manager entirely. Wink

[Image: output.jpg]
find quote
BLKMGK Offline
Donor
Posts: 1,738
Joined: Jul 2006
Reputation: 4
Location: USA Virginia
Rainbow   
Post: #43
hikaricore Wrote:The thing I don't get is that since xbmc already supports multiple audio tracks including (if I'm not mistaken) EXTERNAL audio tracks that aren't part of the original file, why would support for video tracks be that much more difficult? The ffmpeg argument seems like a cheap copout especially considering as you've said they've used unofficial patches in the past to achieve support for things people requested. The usage of ordered chapters is becoming more and more common and as it stands people either have to watch things in a way they weren't intended to be watched or use an external player for half their collection which seems to miss the point of a unified media manager entirely. Wink

Audio tracks are simply a matter of selecting a different stream in the container, this is also already supported by ffmpeg.

What we're talking about here is much different. A video that contains alternate scenes using ordered chapters is much like a BluRay with Seamless Branching.

BluRay does this by having a video broken up into chapters and a control file (I guess) that tells it to play those videos in a specific order. The way the Matroska container does this is it has a main video with the additional pieces tacked on at the very end. When it gets to a branch it jumps to the new chapter way at the end, plays it, and then jumps back into the video at the proper scene change point to maintain the video. The Xin1 tool actually does things to make certain there are key frames at those break points so that it comes back as seamless as possible.

I am now encoding videos I get that have multiple versions using this tool - 2-3 of them so far. One thing I have notices is that audio isn't always perfect when the movie comes to one of these branch points. In my case since I cannot branch I simply watch the main video through and while doing this on one video the soundtrack seemed to glitch at one point - I am assuming this would have been a possible branch point where it could have played an alternate video scene from the end of the movie. If you watch one of these all the way past the credits you will see the extra scenes I believe FYI.

Anyway, this isn't how BluRay does this and it's not the same as how alternate complete video streams or audio tracks are placed into the Matroska container. Instead it's a little like having binary patches than can be applied at will when needed. This results in a HUGE size savings if you want multiple versions of the same movie, just like it does for BluRay which is damned nice. I looked and one of the movies I have multiple versions of is taking up 80Gig of space on my NAS - this after I transcoded it too. I need to redo that one badly!

I do agree though that if there have been ffmpeg patches submitted for this it would be nice to at least consider them. At this point I do not know what the status of any of those are and haven't seen the traffic from the time they were proposed - I've not had time to dig that deeply into the ffmpeg mailing list archives Shocked If it's anything like the CABAC discussions and VDPAU stuff it could be something as simple as coding style or some way that something was coded they didn't think was graceful enough. Those guys are a tough audience!

Openelec Gotham, MCE remote(s), Intel i3 NUC, DVDs fed from unRAID cataloged by DVD Profiler. HD-DVD encoded with Handbrake to x.264. Yamaha receiver(s)
find quote
robpdotcom Offline
Junior Member
Posts: 7
Joined: Jan 2011
Reputation: 0
Post: #44
BLKMGK Wrote:One thing I have notices is that audio isn't always perfect when the movie comes to one of these branch points.

If the movie contains TrueHD tracks, you should use eac3to to convert them to FLAC (or some other lossless format). If not, the audio will always drift out of sync. In fact, you should always convert TrueHD whenever the source is a seamless branching disc.

Don't worry, you will not lose any quality, and you might even save some space. The only downside is that you will need to convert to LPCM if you need to burn a disc from your back-up.
find quote
hikaricore Offline
Posting Freak
Posts: 1,515
Joined: Dec 2008
Reputation: 0
Location: Tuesday
Post: #45
Right I understand the what you're saying, but there also examples like the OP in this thread where the various video tracks simply are streams in (a) container(s). This basic example shouldn't be difficult at all to support much like the audio tracks. I'd imagine once basic support has been added it wouldn't be as much trouble once the devs understand the process to get into the more complex examples like what you're doing.

[Image: output.jpg]
find quote
Post Reply