PDA

View Full Version : Audio stretching


Anakunda
18th July 2010, 17:29
Hello everybody,

I've made a DVD rip of something, what I want to assign an audio track from another rip of the same thingy.
So I remuxed with 1 ext. audio track and played unfortunatelly the audio is slightly diverging about a 2-4 seconds per that movie.

Now I would need a tool that would either stretch the audio to match the video track, or does calculate proper delay and stretch values for audio track, since the video is stored in MKV and mkv supporting delay/stretch params, right?

Is there such a tool?
Plz. note the stretch should be possible via 2 synchronization points at the start and the end.
TIA

SomeJoe
19th July 2010, 01:46
The command line tool "SoX" can stretch/compress using the "speed" option.

I have used it before to make minor adjustments in an audio track to match a video track. I do it like this:

1. Take source audio #1 (A1), which is the original audio that is in-sync with the video, make a mono channel downconversion, and normalize to -18 dB.
2. Take source audio #2 (A2), which is the new audio that needs stretch/compress, make a mono channel downconversion, and normalize to -18 dB.
3. Import both audio files into Adobe Audition, place them both on the multitrack mixer. If you don't have Adobe Audition, try a freeware multitrack mixer, I have not looked for one or used one, but there is one called MixPad that may work.
4. Line up audio A1 flush at time 0:00:00.000.
5. Pick an early point in the audio, line up A2 with A1 at this early time (zoom in on multitrack mixer to get alignment to the msec). Write down the early time in seconds and milliseconds, i.e. ssss.xxx. Call this time Ea.
6. Find a late point in the audio on A1 and A2 (these will be at different times). Write those times down as well, call them La and Lb.
7. Calculate the change in speed factor = (Lb-Ea)/(La-Ea). This will be >1 if the new audio needs to be sped up, it will be <1 if the new audio needs to be slowed down.
8. Prepare the original multi-channel A2 audio (the replacement audio file) by transcoding it to FLAC format using eac3to. Audio must be FLAC because it needs to be < 4GB for SoX to work with it.
9. Adjust the speed on the new audio using command line:

SoX -S -V3 "<source file.flac>" -C0 "<target file.flac>" speed <speed factor> rate -v 48000

10. Now, need to deal with the new audio in point not matching the original audio in point.
10A. If new audio in point when the Ea point was lined up was later than original audio in point, then you will have to insert silence to beginning of new audio.
10B. If new audio in point when the Ea point was lined up was earlier than original audio in point (ideal case), then all that is needed is to cut off audio from beginning. We will do one of these steps at the same time as encoding in step 11.
11. Encode the adjusted FLAC file to the audio format of your choice using eac3to (AC3, DTS, etc.), while at the same time editing the in point.
11A. If in point is later than original by (example) 5.234 sec, use:

eac3to.exe "<speed-adjusted audio.flac>" "<new audio file.ac3>" 5234ms

11B. If in point is earlier than original by (example) 6.587 sec, use:

eac3to.exe "<speed-adjusted audio.flac>" "<new audio file.ac3>" -6587ms

(Note negative time to cut off audio, positive time to insert silence).

12. Audio now ready to use. If you adjusted in point in step 11, don't forget to adjust subtitles and chapter points when remuxing by the same amount.

Anakunda
19th July 2010, 07:06
Hi SomeJoe,

a lil complicated but it may do the work. remember that there's no audio reencoding needed as mkv supports stretch self (depending on the video player).
I don't have Audiotion, so can do Cool Edit the job for me?

tebasuna51
19th July 2010, 18:30
...remember that there's no audio reencoding needed as mkv supports stretch self (depending on the video player).
I don't have Audiotion, so can do Cool Edit the job for me?
- For audio quality is not recommended at all use the stretch function in mkv container.
- Maybe the problem is because you have different video length: DVD source and TV capture (with commercials cuts not exact) then you need cut or insert silences at points of cuts.
- You can use any audio editor to do the job.

Anakunda
17th March 2011, 10:38
Hello,

I'm back to the task.
I have two avis and need to use audio from 1st in second 1 which is about 2min longer. The more it is complicated that the 1st avi starts later than avi#2 so that I can't use simple stretch from point 0 (is cut)

Now what I did is to extract audio track from 1st avi and downmixed to mono and saved as flac to prevent further quality loos.
Now I opened Vegas and imported avi#2 + saved flac track. I replaced the avi#1 audio track by imported flack track. As I expected it ends about 2min sooner than the video track.

Now, by shifting audio track by Alt+Num4 and Alt+Num6 I found two points as near to beginning as possible and as near to end as possible, where I'm able to find matching point in audio to video.
My question is if Vegas have any function to find appropriate delay and stretch factor and eventually stretch the track for me if I feed it some way these 2 sync points, then save it to flac. If it lacks stretching functionalyty its not such a problem, knowing overal delay and stretch factors I can do in Audition also. But the best solution would be if Vegas given such a synchronizing tool.

Anakunda
6th July 2011, 16:32
HI
Any chance to get a good comparison of tools that provide time stretching?
I wanna simply know which is best for which purpose, ie. for movies with alot of music, or for movies with mostly speech.
There's (except sox and eac3to) also Audition and Sound Forge which offers in current version elastique stretch which looks like the right thing for movies but not sure, anyway I'd really appreciate a comparison of all provided methods and more detailed explanation of all options especially on SF and Audition, as doing many tests with various settings is too time expensive task.