View Full Version : combine several audio streams with different length
lovelove
22nd August 2011, 18:06
Hi, let's say I have 1 video file and 2 audio files which I want to mux all in one file (mkv in my case) and the audio files differ in length.
Is there any other way then lossy (:() time-stretching* one of the audio files? Is there any lossless operation?
If I have just 1 audio file I can adapt the video fps instead, but here ... ?
:thanks:
(*) by lossy time-stretching I am referring to (1) decoding to wav >> (2) lenghtening of the audio track in a wave editor >> (3) re-encoding
hello_hello
23rd August 2011, 09:04
Are you asking if you can change the length of one audio file without time stretching it and also doing it losslessy?
If you want to time stretch it, MKVToolNix will do it when you mux the streams together. Depending on the audio format though, and how much you stretch it, you might hear "glitches".
lovelove
23rd August 2011, 23:40
Are you asking if you can change the length of one audio file without time stretching it and also doing it losslessy?
Basically, yes.
But I am not looking for any specific method.
I am looking for a specific result, namely the 2 audio tracks should be in sync and neither one should be lossily transcoded.
(The disk size penalty of transcoding 6 channels per audio track to a lossless format is too much for me.)
If you want to time stretch it, MKVToolNix will do it when you mux the streams together. Depending on the audio format though, and how much you stretch it, you might hear "glitches".
that was my best hope, too, but this has so far not even once yielded acceptable results for 24/25 time-stretching in MKVmerge. Playback was always glitchy. You would have 1,5s of audio, then 0,5s silence, 1,5s audio, 0,5s silence and so on ...
hello_hello
24th August 2011, 00:27
Sorry, but aside from time stretching, I can't think of a way to change the length of the audio losslessly.
Maybe the next best option would be to save the video twice with a different audio track for each, and change the frame rate for one of them. If it doesn't use more disc space than a lossless audio format would.
Mug Funky
24th August 2011, 02:02
it's a matter of why the audio files are different lengths.
it might be necessary to listen to them...
here's a few possible reasons:
- lengths are different due to 25fps versus 24fps. it will be necessary to either resample one to make it faster, or timestretch it. you might be able to patch the samplerate by editing the mkv file, but i'm not sure.
- lengths are different because the films are 2 different cuts of the same film. you'll have to edit one down to fit the other, and hope it's a simple cut-down and there's no missing scenes
- lengths are different because one has been transferred from film without being locked to a video framerate. this can happen with old films from crappy sources - some (very) old telecine machines have the ability to play the film at an arbitrary speed with respect to the output video rate. also, some transfers were done on a setup that is effectively a projector with a camera pointing at it. these can not only be any speed, but they can change speed as the film goes. this will require a re-edit.
- lengths are different because of bits of silence at the start and end. just trim these off and you're fine.
lovelove
25th August 2011, 21:08
@hello_hello: thanks for having looked into this.
@Mug Funky: ok, I am sorry, I wasn't precise enough. Yes, the audio files are properly aligned, i.e. begin and end match (either in the first place or after I cut silence). The reason for the length difference is that the audio was extracted from video with different frame rate (e.g. 24 and 25 fps).
lengths are different due to 25fps versus 24fps. it will be necessary to either resample one to make it faster, or timestretch it. you might be able to patch the samplerate by editing the mkv file, but i'm not sure.
Well, as mentioned above, you can time-stretch the audio during remuxing to mkv. MKVmerge doesn't complain, but VLC playback suffers from glitchy audio. I only tested with VLC because it is the standard reference. I doubt any other player can handle such files correctly, but maybe .... someone knows?
What do you mean by resampling?
Normally resampling means changing the frequency (Hz), but this doesn't change the speed at all, it only affects the audio quality.
hello_hello
27th August 2011, 03:26
I only tested with VLC because it is the standard reference. I doubt any other player can handle such files correctly, but maybe .... someone knows?
I'm not sure I'd call VLC a standard reference, but try Media Player Classic Home Cinema. I think it's a better player.
Whether the audio is glitchy can depend on the type of audio you're stretching. Compressed audio tends to be less "stretchable" than uncompressed audio,
What do you mean by resampling?
Normally resampling means changing the frequency (Hz), but this doesn't change the speed at all, it only affects the audio quality.
I assume he means re-encoding while time stretching. If you time stretch the video while re-encoding it you'd have to resample it to keep the sample frequency the same as the original.
lovelove
3rd September 2011, 00:13
I'm not sure I'd call VLC a standard reference, but try Media Player Classic Home Cinema. I think it's a better player. AFAIR I tested with MPC-HC too. Same thing.
What's so ironic about all this, is that VLC does a really good job at timestretching on-the-fly (i.e. changing playback speed), even without pitch shifting (like MPC-HC does). So it's inconceivable to me how VLC can do so well spontaneously with any file, yet fail so miserably on a time-stretched mkv that was expressly prepared for that task well in advance.
Whether the audio is glitchy can depend on the type of audio you're stretching. Compressed audio tends to be less "stretchable" than uncompressed audio,
it was either an ac3 or aac movie audio track with a high enough bitrate that it was basically transparent to my ears. I don't think that has any implications (as long as we are not talking really low-end audio).
I assume he means re-encoding while time stretching. If you time stretch the video while re-encoding it you'd have to resample it to keep the sample frequency the same as the original. I don't follow you here. Sure you didn't rather mean "avoiding pitch shifting" by any chance (because that has nothing to do with the sampling frequency) ?
lovelove
3rd September 2011, 00:15
It's not like I hadn't been warned. MKVmerge's tooltip for the stretching parameter is:
"Works best on video and subtitle tracks." :-)
djmasturbeat
23rd September 2011, 04:50
i am running into a similar problem.
in my case, I want to remux back to BluRay disc.
I am working on a BD movie (@23.976 fps), and I am taking an audio from a PAL DVD (@25 fps)disc to add to it. I extracted the ac3 audio from the VOBs with eac3to and unpacked to wav files so i can work with the DVD audio losslessly (I will just add it to the BD as LPCM, since there is room and likely bitrate, too). I did use the -slowdown switch in eac3to, but after syncing the audio, I find that it still goes out of sync over the course of the film.
since it isn't a TV show, I don't have any usual places that may be different with delays, like ad breaks. I suspect it is because the PAL audio comes from what was originally a US release of the film, but there hasn't been a US DVD release with this particular audio on it (it was last released with this audio track on mono VHS in the US, and has only received PAL DVD releases, my R4 copy at least is stereo, not sure about the R2UK).
tl;dr, I think it may suffer some conversion from NTSC->PAL then back, but i certainly am no expert here.
It isn't a lot of time, but it is still a bit annoying to me that i can only sync the beginning, the end, the middle, or w/e. everything else is a bit off.
I had thought of doing the middle to spread it out in both directions, but certain things are off sync regardless.
Since I am already doing this track losslessly, how can i do this needed timestretch? can i do this with eac3to? (I am pretty new to using eac3to, and i haven't really written any avs scripts, so excuse the ignorance)
thanks for any help
fwiw, here was my eac3to cli from the log:
eac3to v3.18
command line: "C:\eac3to\eac3to.exe" "H:\VIDEO_TS\VTS_04_1.VOB"+"H:\VIDEO_TS\VTS_04_2.VOB"+"H:\VIDEO_TS\VTS_04_3.VOB"+"H:\VIDEO_TS\VTS_04_4.VOB"+"H:\VIDEO_TS\VTS_04_5.VOB"+"H:\VIDEO_TS\VTS_04_6.VOB" 5: "D:\AKIRA_PREP\akira r4 dvd\Streamline_2.0_eac3todemux.wav" -slowdown
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.