Log in

View Full Version : How to delay the video?


hkl8324
6th August 2007, 13:44
I can only find the delayaudio() function in avisynth but not delayvideo...

nullstuff
6th August 2007, 14:16
...what's the point in delaying video? btw, I guess you may do a "sort of" video-delay using trim() for negative and blankclip() for positive delay...

-- nullstuff

hkl8324
6th August 2007, 15:44
Thanks...
I want video delay because I am making a custom music video by putting some live performance side by side and the source video are not in sync. (of course not)

Dark Shikari
6th August 2007, 16:00
Thanks...
I want video delay because I am making a custom music video by putting some live performance side by side and the source video are not in sync. (of course not)
Why not delay the audio then? Video can only be delayed on a frame-by-frame basis, while audio can be delayed to the millisecond.

nullstuff
6th August 2007, 16:37
...I guess he's making a "stacked" video using two or more live performances (of the same song) taking audio from one clip, so he needs to "delay" other clips to keep them sync'ed. a function like the following will delay video, converting seconds to frames (with a +/- one frame "error"):function delayvideo(clip thiz, float seconds)
{
assert(seconds!=0, "delayvideo: invalid delay value")
tF = abs(round(seconds*float(thiz.framerate)))
delayed = seconds < 0 ? thiz.trim(tF-1,0) : blankclip(thiz, tF) ++ thiz
return delayed
}

-- nullstuff

stickboy
6th August 2007, 17:58
...I guess he's making a "stacked" video using two or more live performances (of the same song) taking audio from one clip, so he needs to "delay" other clips to keep them sync'ed. a function like the following will delay video, converting seconds to frames (with a +/- one frame "error"):function delayvideo(clip thiz, float seconds)
{
assert(seconds!=0, "delayvideo: invalid delay value")
tF = abs(round(seconds*float(thiz.framerate)))
delayed = seconds < 0 ? thiz.trim(tF-1,0) : blankclip(thiz, tF) ++ thiz
return delayed
}You can get millisecond precision if you add or remove frames based on the audiorate and then use DelayAudio with a negated argument (i.e., a negative audio delay is equivalent to delaying the video by a positive amount).

hkl8324
7th August 2007, 09:20
...I guess he's making a "stacked" video using two or more live performances (of the same song) taking audio from one clip, so he needs to "delay" other clips to keep them sync'ed. a function like the following will delay video, converting seconds to frames (with a +/- one frame "error"):function delayvideo(clip thiz, float seconds)
{
assert(seconds!=0, "delayvideo: invalid delay value")
tF = abs(round(seconds*float(thiz.framerate)))
delayed = seconds < 0 ? thiz.trim(tF-1,0) : blankclip(thiz, tF) ++ thiz
return delayed
}

-- nullstuff

This is exactly what I want...
But I am no programmer, I cant understand why the script is written like this, if possible, can you explain to me where should I insert the desired delay time (in sec.)?

nullstuff
7th August 2007, 10:38
...ok, example script:a = avisource("first.avi")
b = avisource("second.avi",false)
stackhorizontal(a,delayvideo(b,3.5))

function delayvideo(clip thiz, float seconds)
{
assert(seconds!=0, "delayvideo: invalid delay value")
tF = abs(round(seconds*float(thiz.framerate)))
delayed = seconds < 0 ? thiz.trim(tF-1,0) : blankclip(thiz, tF) ++ thiz
return delayed
}...1st row loads the "main" movie with sounds; 2nd row loads "secondary" clip without sounds; 3rd row "stacks" the clips delaying the "secondary" by 3.5 seconds (ie, if clip's fps is 25, the delay will be of 88 frames). the delay value can be negative.

-- nullstuff