PDA

View Full Version : How to join dts files properly ?


Music Fan
14th July 2014, 16:21
Hi,
I made a modification on the sound of a little part of a movie (mkv including dts), and to avoid a complete re-encoding I cut the mkv in 3 parts, I decoded the 2nd part in wav (removing dial norm with eac3to), I modified it, I re-encoded it in Dts, I also removed the dial norm of the 2 other parts and I remuxed the 3 dts with video in 3 mkv (I could have removed the dial norm before to cut the movie in 3 parts but I didn't think to that at this moment, now it's too late but it's not a big problem anyway).
Then, if I join the 3 mkv with MKVmerge, it seems ok, I don't hear any glitches at joining points but I wonder if there is a cleaner way to join the 3 dts before the remux in mkv (especially for the dts header) or if MKVmerge is good for this.
eac3to is maybe better for this ?
I also found 2 old programs ; DTStrim and DTSParser but I don't know if there are still useful in 2014.
Thanks ;)

tebasuna51
14th July 2014, 21:55
MkvMerge is ok, BTW you can join dts (with same samplerate, num-channels and bitrate) with a simple binary copy:

copy /b 1.dts + 2.dts + 3.dts Total.dts

Music Fan
15th July 2014, 00:39
Yes, I know this method but I've always been suspicious about this kind of simple command.

Is MkvMerge ok for all formats joining (I mean the formats usually supported by MkvMerge, I'm not talking about exotic codecs) ?

tebasuna51
15th July 2014, 10:52
Yes, I know this method but I've always been suspicious about this kind of simple command.
For what?
The dts format without global header's and with a header for each frame accept this binary copy without problems.
The same method work for AC3 and AAC (with ADTS headers).
Always with same codec parameters.

Is MkvMerge ok for all formats joining (I mean the formats usually supported by MkvMerge, I'm not talking about exotic codecs) ?
I don't test all formats, but must work.
MkvMerge refuse join tracks with different parameters.

Music Fan
15th July 2014, 11:18
For what?
For header's reason, and also because I had problems a few years ago with vob's when cut with Tmpg Dvd Author (there were glitches at joining points while cuts were done on keyframe and there was no re-encoding) while it was ok when done with Mpeg Video wizard (by Womble).
I also have problems with cuts done by a VU+ decoder on TS recordings.
Sometimes, a simple demux in elementary streams and remux solve problems.

tebasuna51
15th July 2014, 19:59
If you cut video+audio by video keyframe you can cut the audio in a half frame.
Never cut both streams muxed, always demux and use DelayCut to cut DTS/AC3/MP3 audio streams.

But this is a problem with the cut, not when join correct DTS streams.

Music Fan
15th July 2014, 21:58
Ok, I note this ;)
But I'm astonished ; if a mkv is split in 3 parts with MKVMerge, do you believe that the sound can be incorrectly cut ?
I suppose that whatever the cut precision, the second part will begin exactly on the sample following the last of the first part, isn't it ?

Overdrive80
15th July 2014, 23:21
Mkvmerge cuts by video´s keyframe, if you split matroska file in three parts, you will get three files with precision of video´s frame. Each part could have, at the beginning and end of each part, a repeated audio frame (gap/overlap) or not (clip). At least that's what I think.

tebasuna51
16th July 2014, 12:00
But I'm astonished ; if a mkv is split in 3 parts with MKVMerge, do you believe that the sound can be incorrectly cut ?
I suppose that whatever the cut precision, the second part will begin exactly on the sample following the last of the first part, isn't it ?

When you split a mkv and after join the parts you can have the same problem than with seemless branching Blurays.

You can read http://forum.doom9.org/showthread.php?p=1600694#post1600694 , replace m2ts with mkv's and you can see how you can have glitches even if MkvMerge don't cut audio frames.

sneaker_ger
16th July 2014, 16:23
I'm too lazy to test now but I'm pretty sure mkvmerge does not duplicate or delete any audio frames when splitting. If you re-append such files with mkvmerge again there can indeed be gaps but those are only realized through timecodes and as such will be gone anyway when extracting to raw .ac3. Mkvmerge also has an option for re-appending such previously splitted files seemlessly ("--append-mode track").

Music Fan
17th July 2014, 10:57
You can read http://forum.doom9.org/showthread.php?p=1600694#post1600694
That's not very clear to me (did you cut the sound or it was cut, why ...), and how do you anlayse the sound ?

Music Fan
17th July 2014, 11:00
I'm too lazy to test now but I'm pretty sure mkvmerge does not duplicate or delete any audio frames when splitting.
How can it be verified ?

Mkvmerge also has an option for re-appending such previously splitted files seemlessly ("--append-mode track").
I guess you mean the Append button in the GUI. I believe it's not only for previously splitted files but also for videos with same parameters.

tebasuna51
17th July 2014, 18:04
If is not clear for you maybe go back to the beginning:

I made a modification on the sound of a little part of a movie (mkv including dts), and to avoid a complete re-encoding I cut the mkv in 3 parts, I decoded the 2nd part in wav, I modified it, I re-encoded it in Dts,...

Best method to do the job:

1) Extract the full dts.

2) Split the dts with Delaycut. Select like cut points a moment of silence. You can't do this with MKvmerge and is important to avoid glitches when you join the files.

3) Edit and recode the 2nd part.

4) Join the 3 parts with the binary copy and replace the full dts in the original mkv.

sneaker_ger
17th July 2014, 20:36
I guess you mean the Append button in the GUI. I believe it's not only for previously splitted files but also for videos with same parameters.
Yes, it works through that append button but the default is "--append-mode file". "--append-mode track" would have to be added to the command manually, there is no extra GUI control for it.

2) Split the dts with Delaycut. Select like cut points a moment of silence. You can't do this with MKvmerge
Your delaycut method is fine but I don't see why mkvtoolnix shouldn't be able to do the job as well. :confused:

foxyshadis
17th July 2014, 22:37
Ok, I note this ;)
But I'm astonished ; if a mkv is split in 3 parts with MKVMerge, do you believe that the sound can be incorrectly cut ?
I suppose that whatever the cut precision, the second part will begin exactly on the sample following the last of the first part, isn't it ?

DTS is way too dumb and simple to break it. Unlike MP3 with its bit reservoir, Vorbis with its windowing, and Opus with its one-frame delay, one frame of DTS is exactly 10.67ms of sound and each frame could be individually decoded and reassembled with identical output. (I believe AC3 is the same, at 32ms/frame of course, but I'm not 100% sure what coding tricks it uses.)

tebasuna51
18th July 2014, 10:26
...one frame of DTS is exactly 10.67ms of sound and each frame could be individually decoded and reassembled with identical output.

Sorry but is not exact.

Both, AC3 and DTS decoders, needs a initialization value, supplied from the precedent frame, to output the exact sound.

Make a test like this:

Split a DTS at a point with no silence.
Decode the full dts (upper wave in image) and the 2 parts, join the wavs from the 2 parts (lower wave) and compare.

This is the problem detected here (http://forum.doom9.org/showthread.php?p=1565770#post1565770).

Like MkvToolnix cut by video keyframes you can't select the audio cut point and can produce glitches or not, most the time is not audible but you can't be sure.

Music Fan
18th July 2014, 10:39
Best method to do the job:
Yes, as I said above that's what I plan to do next time but now it's too late, I already made changes.

This is the problem detected here (http://forum.doom9.org/showthread.php?p=1565770#post1565770).
This concerns avisynth, that's maybe different from MkvToolnix which does not decode.

sneaker_ger
18th July 2014, 11:47
Like MkvToolnix cut by video keyframes you can't select the audio cut point and can produce glitches or not, most the time is not audible but you can't be sure.
If you only want to cut audio in mkvmerge you simply deselect the video track -> cut at any point.

This concerns avisynth, that's maybe different from MkvToolnix which does not decode.
It's an inherent problem of the audio format, every software is concerned.

foxyshadis
18th July 2014, 23:30
Sorry but is not exact.

Both, AC3 and DTS decoders, needs a initialization value, supplied from the precedent frame, to output the exact sound.

Make a test like this:

Split a DTS at a point with no silence.
Decode the full dts (upper wave in image) and the 2 parts, join the wavs from the 2 parts (lower wave) and compare.

This is the problem detected here (http://forum.doom9.org/showthread.php?p=1565770#post1565770).

Like MkvToolnix cut by video keyframes you can't select the audio cut point and can produce glitches or not, most the time is not audible but you can't be sure.

Ah, so it is similar to Opus then. Sorry about that. Looks like you'd have to grovel deep in the format to tweak the context IV or the first joined frame to make it fit (or at least always force it to re-initialize at zero).

Music Fan
19th July 2014, 19:35
You can read http://forum.doom9.org/showthread.php?p=1600694#post1600694 , replace m2ts with mkv's and you can see how you can have glitches even if MkvMerge don't cut audio frames.
I read it again but I still don't understand how we can verify if there are duplicated or deleted audio frames after having done cuts.
Does eac3to need the original audio track (uncut) to make comparison ?

sneaker_ger
19th July 2014, 22:35
There will be no duplicated or deleted audio frames if you split your mkv's audio using tebasuna51's delaycut method (post #13) or using mkvtoolnix correctly.

tebasuna51
19th July 2014, 22:46
In your case you have the next problem, even if the cut was made properly (*) without duplicated or missing frames:

Cut the original dts in 3 parts: 1.dts, 2.dts and 3.dts to edit the 2.dts

1) When you decode the 2.dts, without the inicialitation from the last frame of 1.dts, the first frame is bad decoded (see my previous image).

2) After edit and recode the 2.dts the first frame have a inicialization value of silence, when you add 2.dts to 1.dts the decoder try to decode the first frame from 2.dts with the old initialzation value, not with silence, and one more time this frame is bad decoded. Only if cut point is in a audio silence you can be sure don't have glitches.

3) You can have a similar problem in the join point between 2.dts and 3.dts.

(*) I make test with MkvMerge cutting .mka (mkv with only a dts track) and seems work properly, but I don't know how can work with video muxed.

sneaker_ger
19th July 2014, 22:54
(*) I make test with MkvMerge cutting .mka (mkv with only a dts track) and seems work properly, but I don't know how can work with video muxed.

Unchecking the video track in mkvmerge GUI is sufficient for doing arbitrary cuts (as opposed to only on video keyframes).

Music Fan
19th July 2014, 23:41
There will be no duplicated or deleted audio frames if you split your mkv's audio using tebasuna51's delaycut method (post #13) or using mkvtoolnix correctly.
What do you mean by correctly ? Uncheck the video ?

Music Fan
19th July 2014, 23:45
2) After edit and recode the 2.dts the first frame have a inicialization value of silence
Do you mean this can't be avoided because each encoding creates this value of silence ?

(*) I make test with MkvMerge cutting .mka (mkv with only a dts track) and seems work properly
How do you see that ? Just by decoding it to wav and appending files in an audio editor ?

sneaker_ger
20th July 2014, 00:34
What do you mean by correctly ? Uncheck the video ?
Scratch the "correctly": mkvmerge does not duplicate or delete audio frames. There are ways to screw it up when re-encoding the spitted part, though.

tl;dr: just follow the tutorial from post #13 and you will be fine.

tebasuna51
20th July 2014, 07:37
Do you mean this can't be avoided because each encoding creates this value of silence ?
Yes, all encoding begin with silence, for that there aren't problems if cut is make in a silence point.

How do you see that ? Just by decoding it to wav and appending files in an audio editor ?
Yes, for this image, or you can join the dts's and after decode to wav and see the cut point, there are always a glitche, audible or not.

Music Fan
20th July 2014, 10:36
Ok, thank you guys ;)

Yes, all encoding begin with silence, for that there aren't problems if cut is make in a silence point.
But the duration is the same, right ?
In other words, does the value of silence replace the first sample or is it added before ?
If it's added, this logically means that the sound following this very short silence is a little bit delayed compared to the original track and the total audio track duration is a little bit longer (but too briefly to be noticed).

there are always a glitche, audible or not
And there is no way to remove this silence ?

filler56789
20th July 2014, 11:49
In other words, does the value of silence replace the first sample or is it added before ?
If it's added, this logically means that the sound following this very short silence is a little bit delayed compared to the original track and the total audio track duration is a little bit longer

http://forum.doom9.org/showthread.php?t=164363

(but too briefly to be noticed).

It depends. NeroAACenc is well-known for adding a HUGE audio delay (around 1 video frame @ 24, 25 or 30 fps), and some people are more sensitive to this problem.