Seamlessly branching multi-disc movies with Atmos
- horseshowers
- Posts: 20
- Joined: Sun Jul 16, 2023 4:09 am
Seamlessly branching multi-disc movies with Atmos
Hi,
I'm making a backup of my LOTR Extended films, and in that process I want to combine the two discs into one MKV file. I did that with MakeMKV and MKVToolnix (separating out the appropriate black frames and then merging), which works perfectly when played in VLC. However, if I play it through my home theatre, there is a 1s audio gap where my AVR prepares to play the next Atmos track. This is obviously not ideal.
I know DGDemux can properly combine two Atmos tracks as long as they're part of the same on-disc playlist. Is there some part of this program that can do this with these two Atmos tracks that have had the end and start silence removed, respectively? Or if not, are you able to point me towards a program that can help me achieve what I'm trying to do?
I'm making a backup of my LOTR Extended films, and in that process I want to combine the two discs into one MKV file. I did that with MakeMKV and MKVToolnix (separating out the appropriate black frames and then merging), which works perfectly when played in VLC. However, if I play it through my home theatre, there is a 1s audio gap where my AVR prepares to play the next Atmos track. This is obviously not ideal.
I know DGDemux can properly combine two Atmos tracks as long as they're part of the same on-disc playlist. Is there some part of this program that can do this with these two Atmos tracks that have had the end and start silence removed, respectively? Or if not, are you able to point me towards a program that can help me achieve what I'm trying to do?
Seamlessly branching multi-disc movies with Atmos
Welcome to the forum, horseshowers, and thank you for your question.
Deleting video by hand without deleting the corresponding audio is problematic. I guess you know that now.
We need to know if the silence/blackness is confined to a single M2TS. Then you could use skip_first and skip_last as needed. Load the first disk into DGDemux. Choose your playlist and then highlight the first M2TS in the list and hit Preview. If it contains only the silence/blackness then skip_first will get rid of it. Ditto for skip_last. If it looks that way, then you can demux with those needed options. Then you can do the same for the second disk. Then for video merge the two by hand using binary copy (copy /b file1+file2 out). Do the same for your audio. Now mux the resulting streams into MKV.
If the silence/blackness is not contained in separate M2TS files, we'll have to
some more.
Deleting video by hand without deleting the corresponding audio is problematic. I guess you know that now.
We need to know if the silence/blackness is confined to a single M2TS. Then you could use skip_first and skip_last as needed. Load the first disk into DGDemux. Choose your playlist and then highlight the first M2TS in the list and hit Preview. If it contains only the silence/blackness then skip_first will get rid of it. Ditto for skip_last. If it looks that way, then you can demux with those needed options. Then you can do the same for the second disk. Then for video merge the two by hand using binary copy (copy /b file1+file2 out). Do the same for your audio. Now mux the resulting streams into MKV.
If the silence/blackness is not contained in separate M2TS files, we'll have to
![Thinking :scratch:](./images/smilies/icon_scratch2.gif)
Seamlessly branching multi-disc movies with Atmos
Hi horseshowers
I have also experience with such movies and in the beginning of using MKV, I had also cut streams and append them and so on.
But I use now an easier method, called Ordered Chapters.
VLC can handle Ordered Chapters but not perfect. MPC-HC/BE or mpv are better.
Only with Ordered Chapters you are able to cut and merge video/audio content frame exactly and all is done virtually.
This means you don't need cut and merge something.
With my chapterEditor is it easy to create the needed Ordered Chapters.
https://forum.doom9.net/showthread.php?t=169984
I have also experience with such movies and in the beginning of using MKV, I had also cut streams and append them and so on.
But I use now an easier method, called Ordered Chapters.
VLC can handle Ordered Chapters but not perfect. MPC-HC/BE or mpv are better.
Only with Ordered Chapters you are able to cut and merge video/audio content frame exactly and all is done virtually.
This means you don't need cut and merge something.
With my chapterEditor is it easy to create the needed Ordered Chapters.
https://forum.doom9.net/showthread.php?t=169984
Seamlessly branching multi-disc movies with Atmos
Thank you, hubblec4. Easier is usually better, but I'm a pedal to the metal kind of squirrel.
Feel free to support horseshowers using cE here if you like. I can learn too.
![grateful :salute:](./images/smilies/icon_salute.gif)
![Crying or Very Sad :cry:](./images/smilies/icon_cry.gif)
Feel free to support horseshowers using cE here if you like. I can learn too.
![grateful :salute:](./images/smilies/icon_salute.gif)
- horseshowers
- Posts: 20
- Joined: Sun Jul 16, 2023 4:09 am
Seamlessly branching multi-disc movies with Atmos
Thank you. It's refreshing to meet a dev that actually cares about the user.
I did delete the video and audio together, they are in sync, and it works perfectly with the AC3 fallback track and the commentary tracks. The issue is only with splicing the two Atmos tracks together, and only with bitstream to AVRs (at least with my Denon, and I assume it happens with other AVRs too).Deleting video by hand without deleting the corresponding audio is problematic. I guess you know that now.
I'm not even sure if this is something that can be done in the MKV or if it has to be fixed in the player, like multi-file UHD films had to be - the Exoplayer on my Shield still can't play Apocalypse Now properly because it was split up on the disc: https://github.com/google/ExoPlayer/issues/10520
The silence and blackness is contained in the M2TS files, unfortunately.We need to know if the silence/blackness is confined to a single M2TS.
If the silence/blackness is not contained in separate M2TS files, we'll have tosome more.
Ordered Chapters are a very cool feature, but it's my understanding that Plex doesn't support it, and thus it's sadly useless to me. Thanks for the tip tho.
Seamlessly branching multi-disc movies with Atmos
Yes, Plex is a very cool video playback tool, but the missing support of Ordered Chapters in this times is very shame. Maybe if MKV is more popular, then Plex will add ordered chapter support.
Seamlessly branching multi-disc movies with Atmos
As documented in other threads here, we discovered when implementing gaps correction you cannot arbitrarily cut and recombine THD and Atmos audio. It has to be done in a very specific way. If the rules aren't followed problems like those you are experiencing can occur.
- horseshowers
- Posts: 20
- Joined: Sun Jul 16, 2023 4:09 am
Seamlessly branching multi-disc movies with Atmos
I tried to search around on the forums before posting but didn't find anything useful. You got any links? I just want the audio to be seamless, the way it was clearly intended to be seeing as they didn't even add a fade when splitting the disc.Rocky wrote: ↑Tue Jul 18, 2023 6:03 amAs documented in other threads here, we discovered when implementing gaps correction you cannot arbitrarily cut and recombine THD and Atmos audio. It has to be done in a very specific way. If the rules aren't followed problems like those you are experiencing can occur.
Seamlessly branching multi-disc movies with Atmos
I knew you were gonna ask that. Rather than point you to a massive thread, I'll explain it here.
THD/Atmos has what are called major and minor frames. A stream starts with a major frame and that is followed by a bunch of minor frames (call that a cycle). Then another major and a bunch of minors, etc. Looks like this:
+----------------+-------------- etc.
What we found is that to cut any of this audio (in the compressed domain) without annoying the decoders, you have to cut only minors from the end of a cycle, or full cycles. In your case we have:
The asterisks are audio you want to remove because it corresponds to black frames.
You cannot cut just the asterisks because it violates the rules at the beginnings of the streams. You could cut an entire cycle, however, so that the disk streams still start with a major. Cutting from the end is fine because that always follows the rules.
Bottom line: your cutting must be cycle-aware. Cut only full cycles or minors from the end of a cycle. DG gaps correction always removes minors from the end of the last cycle of an M2TS.When the silence/blackness is confined to a leading/trailing M2TS things are easy -- just get rid of that M2TS. If not, well, you'll need some special processing or a special tool, which I don't think anyone has provided.
Of course you can just decode everything to raw audio/video, cut as you like, and re-encode. That might be the best option for you.
THD/Atmos has what are called major and minor frames. A stream starts with a major frame and that is followed by a bunch of minor frames (call that a cycle). Then another major and a bunch of minors, etc. Looks like this:
+----------------+-------------- etc.
What we found is that to cut any of this audio (in the compressed domain) without annoying the decoders, you have to cut only minors from the end of a cycle, or full cycles. In your case we have:
Code: Select all
+--------------------- (end of first disk stream)
+--------------------- (beginning of second disk stream)
*** ***
You cannot cut just the asterisks because it violates the rules at the beginnings of the streams. You could cut an entire cycle, however, so that the disk streams still start with a major. Cutting from the end is fine because that always follows the rules.
Bottom line: your cutting must be cycle-aware. Cut only full cycles or minors from the end of a cycle. DG gaps correction always removes minors from the end of the last cycle of an M2TS.When the silence/blackness is confined to a leading/trailing M2TS things are easy -- just get rid of that M2TS. If not, well, you'll need some special processing or a special tool, which I don't think anyone has provided.
Of course you can just decode everything to raw audio/video, cut as you like, and re-encode. That might be the best option for you.
- horseshowers
- Posts: 20
- Joined: Sun Jul 16, 2023 4:09 am
Seamlessly branching multi-disc movies with Atmos
I see. Thanks for the very good explanation. I take it you're not aware of a tool that can help me determine good cut-points? Is the cycle always the same length or does it vary, and if the former, how long is it?Rocky wrote: ↑Tue Jul 18, 2023 11:48 amI knew you were gonna ask that. Rather than point you to a massive thread, I'll explain it here.
Bottom line: your cutting must be cycle-aware. Cut only full cycles or minors from the end of a cycle. DG gaps correction always removes minors from the end of the last cycle of an M2TS.When the silence/blackness is confined to a leading/trailing M2TS things are easy -- just get rid of that M2TS. If not, well, you'll need some special processing or a special tool, which I don't think anyone has provided.
If it was just TrueHD I'd do that, easiest thing in the world, but I don't know of any way to do it while keeping the Atmos metadata.Of course you can just decode everything to raw audio/video, cut as you like, and re-encode. That might be the best option for you.
Seamlessly branching multi-disc movies with Atmos
Cycles can vary in length.
Using the same technology as our gaps correction for THD/Atmos, I could whip up a small utility for editing THD/Atmos streams. Easiest would be to just allow for cuts at the beginning and end, specified by amount of time to cut. Edited streams could then be concatenated without issues. It would be up to you to cut the video accordingly. More general would be to allow cuts anywhere. I'll experiment with this after I finish up the DTS Express support.
Using the same technology as our gaps correction for THD/Atmos, I could whip up a small utility for editing THD/Atmos streams. Easiest would be to just allow for cuts at the beginning and end, specified by amount of time to cut. Edited streams could then be concatenated without issues. It would be up to you to cut the video accordingly. More general would be to allow cuts anywhere. I'll experiment with this after I finish up the DTS Express support.
Seamlessly branching multi-disc movies with Atmos
If you don't mind remuxing to MKV, there may be a solution with MKVToolnix:
https://forum.videohelp.com/threads/400 ... lby-TrueHD
Read the entire thread.
I think even if it can be coerced into doing what you want, my proposed approach is simpler and more direct.
TSMuxer may also be an option. 'Split & cut' on the M2TS.
https://forum.videohelp.com/threads/400 ... lby-TrueHD
Read the entire thread.
I think even if it can be coerced into doing what you want, my proposed approach is simpler and more direct.
TSMuxer may also be an option. 'Split & cut' on the M2TS.
- horseshowers
- Posts: 20
- Joined: Sun Jul 16, 2023 4:09 am
Seamlessly branching multi-disc movies with Atmos
That would be much appreciated. Do you have any idea how long it may take you? Don't want to rush you, I'd just like to know how long of a wait I can expect.Rocky wrote: ↑Wed Jul 19, 2023 6:18 amUsing the same technology as our gaps correction for THD/Atmos, I could whip up a small utility for editing THD/Atmos streams. Easiest would be to just allow for cuts at the beginning and end, specified by amount of time to cut. Edited streams could then be concatenated without issues. It would be up to you to cut the video accordingly. More general would be to allow cuts anywhere.
MKVToolnix is how I cut the files initially.
Since starting this thread I've also successfully extended an Atmos track from the Hobbit 3 by 2s to properly sync it up with the 3D bluray and that worked perfectly. Idk if I just got lucky with my cut points or if it's because every audio part I worked with came from the same M2TS track originally.
Seamlessly branching multi-disc movies with Atmos
A few days just to make the utility. Ideally, I'd like to get the disks and test with those. Speaking of which, can you give me a link to purchase them, preferably from amazon? I need the exact same disks you are using.
Without knowing exactly what you did (full process) it's hard to comment. Let's leave that aside for now and see how I get on.Since starting this thread I've also successfully extended an Atmos track from the Hobbit 3 by 2s to properly sync it up with the 3D bluray and that worked perfectly. Idk if I just got lucky with my cut points or if it's because every audio part I worked with came from the same M2TS track originally.
- horseshowers
- Posts: 20
- Joined: Sun Jul 16, 2023 4:09 am
Seamlessly branching multi-disc movies with Atmos
Cool, thanks for info.
I'm not entirely sure it's the exact same discs as I didn't buy them from Amazon, but the pictures here match my box set.Ideally, I'd like to get the disks and test with those. Speaking of which, can you give me a link to purchase them, preferably from amazon? I need the exact same disks you are using.
I could alternatively send you a full disc copy of one of the movies to ensure you have the exact same files I'm working with, purely for research purposes of course and I expect you will delete the files when you're done.
Seamlessly branching multi-disc movies with Atmos
How would you do that?
EDIT: Are you looking to keep the embedded AC3? That affects the design of the utility.
- horseshowers
- Posts: 20
- Joined: Sun Jul 16, 2023 4:09 am
Seamlessly branching multi-disc movies with Atmos
I already have all the discs ripped to my drive, I could upload one of the films to gofile and send you the link, or make a private torrent.
It doesn't matter to me, since MakeMKV puts that onto a separate track, and combining the AC3 tracks doesn't cause any issues. However it might matter to someone else, so I'll leave that decision to you.EDIT: Are you looking to keep the embedded AC3? That affects the design of the utility.
Seamlessly branching multi-disc movies with Atmos
Do it!horseshowers wrote: ↑Wed Jul 19, 2023 12:09 pmI already have all the discs ripped to my drive, I could upload one of the films to gofile and send you the link
EDIT: I will have a test version of the utility for you later this evening.
![Wow :wow:](./images/smilies/icon_eek2.gif)
- SomeHumanPerson
- Posts: 96
- Joined: Fri Mar 24, 2023 10:41 am
Seamlessly branching multi-disc movies with Atmos
If you end up making the generalized version (cut anywhere, roughly speaking), that would be amazing. In theory that should allow for some ability (maybe not perfect depending on the size of these groupings you describe) to make arbitrary sync corrections on Atmos tracks without losing the Atmos (currently impossible AFAIK).
I should probably prepare for my hopes to be dashed by physics and math.
I should probably prepare for my hopes to be dashed by physics and math.
Seamlessly branching multi-disc movies with Atmos
Nah, it's a walk in the park. Two days maximum, given how easy this first version was.SomeHumanPerson wrote: ↑Wed Jul 19, 2023 7:09 pmI should probably prepare for my hopes to be dashed by physics and math.
![Surprised :o](./images/smilies/icon_e_surprised.gif)
Here is an initial test version. It supports cutting at the beginning and end. Streams are THD only, no embedded AC3.
thdtrim infile.thd outfile.thd secs_to_cut_at_start secs_to_cut_at_end
E.g., cut 10.5 secs at start and 3.3 at end:
thdtrim test.thd out.thd 10.5 3.3
You would trim your first disk stream, then your second disk stream, and then join them by:
copy /b out1.thd+out2.thd final.thd
Let me know if it works, i.e., decoders are happy with the result. Basic testing was OK for me.
https://rationalqm.us/misc/horseshowers.zip
As Sherman would say: YMBDN
- SomeHumanPerson
- Posts: 96
- Joined: Fri Mar 24, 2023 10:41 am
Seamlessly branching multi-disc movies with Atmos
How precise is this going to be? As in, what range of durations can be expected in these frame cycles that are the limitation on where you can cut? Is it always/typically/maybe/never going to be sub-video-frame timing?
Can you provide feedback from the tool as to exactly where you end up making the cut (if that is meaningful based on the answer to the questions above)?
(Sorry if these questions are dumb; I'm not well versed in audio encoding implementations.)
Can you provide feedback from the tool as to exactly where you end up making the cut (if that is meaningful based on the answer to the questions above)?
(Sorry if these questions are dumb; I'm not well versed in audio encoding implementations.)
Seamlessly branching multi-disc movies with Atmos
Great questions. Well, it's not great. Typically:
For the starting cut, the worst case is 72ms off from what you ask for, with the average case at 36ms.
For the end cut the worst case is 0.6ms.
Yes, I can output the actual cut points.
Sync correction as in our gaps correction is always 0.6ms granular, because we always remove minors. Trimming is a different animal, because streams must start with a major.
For the starting cut, the worst case is 72ms off from what you ask for, with the average case at 36ms.
For the end cut the worst case is 0.6ms.
Yes, I can output the actual cut points.
Sync correction as in our gaps correction is always 0.6ms granular, because we always remove minors. Trimming is a different animal, because streams must start with a major.
- SomeHumanPerson
- Posts: 96
- Joined: Fri Mar 24, 2023 10:41 am
Seamlessly branching multi-disc movies with Atmos
Thank you, that's very helpful information.
- horseshowers
- Posts: 20
- Joined: Sun Jul 16, 2023 4:09 am
Seamlessly branching multi-disc movies with Atmos
Sent you a PM. Took a while to upload due to the size, will probably take a while to download as well.Rocky wrote: ↑Wed Jul 19, 2023 12:36 pmDo it!horseshowers wrote: ↑Wed Jul 19, 2023 12:09 pmI already have all the discs ripped to my drive, I could upload one of the films to gofile and send you the link
Great! I'll download it now and see if it works.EDIT: I will have a test version of the utility for you later this evening.![]()
Edit: tested it, same issue unfortunately. The files play perfectly in VLC on my PC, but when playing Atmos through my AVR I get the audio dropout at the joint.
Seamlessly branching multi-disc movies with Atmos
Please tell me your command lines used for the trimming so I can duplicate what you did.
I don't have an AVR so if it is not something obvious then we may be at the end of what I can do.
EDIT: If you just join the streams without trimming, does it drop out?
EDIT2: How long is the dropout? Does audio recover?
I don't have an AVR so if it is not something obvious then we may be at the end of what I can do.
EDIT: If you just join the streams without trimming, does it drop out?
EDIT2: How long is the dropout? Does audio recover?