Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 29th October 2013, 05:24   #1  |  Link
tyee
Registered User
 
Join Date: Oct 2001
Posts: 397
DelayAudio leaves dropout at edit point

Ok, I'm trying to replace a foreign language with an english version and it's coming along nicely until now. The foreign language video is a slightly different cut of the movie than the cut the audio is from but close enough to make it work.

At a cut point I've chosen, the audio needs delaying 1.5 secs because the video has a few extra frames, so I use delayaudio(1.5) and it works, resynching the video and audio, however this causes a 1.5 sec dropout in the audio portion of the soundtrack. I'm actually using that delayaudio command like so -
trim(x,y).delayaudio(1.5), where x is the next frame after the last edit, so initially I was not cutting any video.

So I thought, let's cut 1.5 sec off the video also by jumping ahead 36 frames and see if that prevents the audio dropout, Nope! So, what to do to prevent the dropout and butt the video and audio up against the previous edit point?

Last edited by tyee; 29th October 2013 at 05:26.
tyee is offline   Reply With Quote
Old 29th October 2013, 05:36   #2  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 3,414
one approach would be to keep the video as is, and pad the audio (add silence to the beginning of audio)
poisondeathray is offline   Reply With Quote
Old 29th October 2013, 06:09   #3  |  Link
tyee
Registered User
 
Join Date: Oct 2001
Posts: 397
Yes, I really want to keep all the video as is. The whole movie has to have different audio delays in different parts, that's what I'm trying to do. To simplify my problem, take any video with audio, delay the audio by 5 seconds at the start. To get rid of the 5 sec of silence at the start, how do you shift the audio track back to frame 0 of the clip. Yes, I know they won't be in sync in this example but it's the method to do it I'm trying to understand.

Ok, figured it out. Instead of using trim(x,y).delayaudio(1.5), where this adds delay to clip xy, which adds silence, I have to use this -

DelayAudio(0.2).Trim(82846,98583) + DelayAudio(1.5).Trim(98584,0)

The secret is using the whole movie as the input to the delayaudio function, then trimming with the trim command to select the delayed audio clip.

Last edited by tyee; 29th October 2013 at 07:39.
tyee is offline   Reply With Quote
Old 29th October 2013, 08:44   #4  |  Link
sven_x
Registered User
 
Join Date: Oct 2011
Location: Germany
Posts: 39
I have solved such a problem by time-stretching audio (not cutting) with an advanced audio editor, such as Steinberg Wavelab. It is a tricky procedure.
First you have to write down the dealy times that your video has at several points.
You will get a list of this kind:

Code:
0       0 ms
5min   200 ms
15 min 200 ms
20 min 100 ms
As you can see, the delay is not equally distributed.
To be able to correct the delay you have to calculate the Delta values of the delays.

Code:
0       0 ms     0
5min   200 ms  0,2
15 min 200 ms    0
20 min 100 ms -0,1
In this example you have to stretch the audio parts
(0...5min) to (running time + 200 ms)
(5min...15min) do nothing
(15min...20min) to (running time - 100 ms)

Of course one should a use a algorithm that does not change pitch.

How do you get the delay times?
Well, that is the tricky part. You can do it by trial. Most video players have an option to delay audio for a fixed number of milliseconds. Just play with that value, until audio is synchronized to video. The accuracy of this method is about 100ms at each point. Then go, say one minute forward in the video and check synchronisation again. If the video is not in sync anymore, you have to search again for a proper delay value at this point.
Needless to say - the whole procedure is very time consuming.

Last edited by sven_x; 29th October 2013 at 09:30.
sven_x is offline   Reply With Quote
Old 29th October 2013, 18:23   #5  |  Link
tyee
Registered User
 
Join Date: Oct 2001
Posts: 397
Thanks Sven for the info. Yes, it is very time consuming but I am going to finish. I thought about loading Sony Vegas or another big editor to do this but I don't really want to. I'm not sure Vegas could do it?

It's quite fun once I got the procedure down. I'm not sure I could use your method because the video portion of mine has extra frames added, like someone else edited it, compared to the version I got the audio from. In one part I have a 3 second delay required. Would stretching work in this case?

Last edited by tyee; 29th October 2013 at 18:28.
tyee is offline   Reply With Quote
Old 31st October 2013, 23:25   #6  |  Link
Richard1485
Registered User
 
Join Date: Feb 2010
Posts: 216
Use Loop().
Richard1485 is offline   Reply With Quote
Old 2nd November 2013, 00:22   #7  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,168
Trim and DelayAudio are not commutative, i.e. order matters.

If we examine what happens with SomeSource(...).Trim(...).DelayAudio(...)
Code:
SomeSource(...)

|vvvvvvvvv|
|aaaaaaaaa|

Trim(...)

...|vvv|...
...|aaa|...

DelayAudio(...)

...|vvv|...
...|__aaa|...
we see the whole 2 input streams, then Trim cuts out an aligned section of the 2 streams, then DelayAudio shifts the audio stream by inserting silence at the start. Note the end of the audio now pokes out past the end of the video.

And compare it with SomeSource(...).DelayAudio(...).Trim(...)
Code:
SomeSource(...)

|vvvvvvvvvv|
|aaaaaaaaaa|

DelayAudio(...)

|vvvvvvvvvv|
|__aaaaaaaaaa|

Trim(...)

...|vvv|...
...|_aa|...
again we see the whole 2 input streams, then DelayAudio shifts the audio stream by inserting silence at the start, the end of the audio pokes out past the end of the video. Then Trim cuts out an aligned section of the 2 streams. Note the start and end of the 2 streams are synchronised. If the Trim includes some of the inserted silence, then that is also in the result.

A similar thing happens if the delay value is negative. Instead of inserting silence at the start, some of the start samples are removed and the end of the audio is shorter than the video.

The distinction becomes particularly relevant when using aligned versus unaligned splice "++" and "+" respectively.
IanB is offline   Reply With Quote
Old 2nd November 2013, 07:23   #8  |  Link
tyee
Registered User
 
Join Date: Oct 2001
Posts: 397
Yes, excellent description. That's exactly what I needed. The beginning of my source is in sync so I never see that delay at the start and all the other trims I cut are delayed properly. Actually I just finished trimming/delaying. I now have to mux the new audio with the video and watch the whole movie and make sure it's in sync.

How would loop() help with this?
tyee is offline   Reply With Quote
Old 2nd November 2013, 14:13   #9  |  Link
Richard1485
Registered User
 
Join Date: Feb 2010
Posts: 216
I do the sort of work that you're doing all the time and would either loop a short section of the audio (where/if doing so would not be noticeable) or dissolve the audio track into itself, rather than inserting silence.
Richard1485 is offline   Reply With Quote
Old 2nd November 2013, 22:03   #10  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,168
Loop() is used to repeat a segment of a stream a specified number of times.

So you can use it to fill gaps where the sound does not need to lip sync the video, like with back ground music.

You can manufacture your own gap fills by trimming and assembling appropriate sections of the audio track then using AudioDub() to associate the new audio with the video.

Instead of using a hard join to splice segments you can use Dissolve() to fade between two segments with some overlap.
IanB is offline   Reply With Quote
Old 3rd November 2013, 06:20   #11  |  Link
tyee
Registered User
 
Join Date: Oct 2001
Posts: 397
Hi guys
I finished my editing and actually did post my results here in a new thread but I'm not 100% sure if I should be doing this. The script I made must be used with 2 actual blu-rays and I must obviously give the names of them and where to get them (amazon). Is this ok? This script creates a unique english audio track, but following the directions anyone can easily do it themselves. If anything it will create more sales of these two movies which is not my intention.

A similar post was made on avsforum in 2009 regarding another movie in this series and it's still there so they didn't mind.

I deleted my thread.

Last edited by tyee; 3rd November 2013 at 07:04.
tyee is offline   Reply With Quote
Old 3rd November 2013, 22:12   #12  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 1,987
Quote:
Originally Posted by tyee View Post
I thought about loading Sony Vegas or another big editor to do this but I don't really want to. I'm not sure Vegas could do it?
Next time, use Vegas. It can do what you describe, and it would probably take less than ten minutes to finish the job. You simply cut the audio at places where it isn't in sync. You then look for easy sync points where the person's lips come together ("p", "m", & "b" for instance). You cut this event just before the point you have synced, and line up the audio waveform with the point where the lips come together (turn off frame locking before you do this).

You then look for a much later section of the video, and find another place where the actor is talking. Cut the event just after the point at which you are going to sync. Then, "Ctrl-Drag" the end of the audio event until you line up the plosive in the audio waveform with the actor's lips coming together. This will change the duration of the audio without changing the pitch. If you have a Vegas version from version 9 onward, make sure that "Elastique" is selected in the audio event properties. This newer technology does an unbelievable job of changing audio duration, without changing pitch, and without introducing any audible artifacts, even when changing speeds by more than 10%.

If there is a discontinuity in the audio and video, you will have to repeat this procedure at each discontinuity point.

I have done this dozens and dozens of times. I would never think of using AVISynth for this task because the quality of the audio re-syncing is not as good and because it is not interactive.
johnmeyer is offline   Reply With Quote
Old 3rd November 2013, 23:07   #13  |  Link
tyee
Registered User
 
Join Date: Oct 2001
Posts: 397
Yes, I did use Vegas a few years ago on an older computer and haven't reloaded it on the new one. Thanks for the info though. I wonder if AVSPmod would be just as slow?
tyee is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:51.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.