View Full Version : Is there an equivalent to DeleteFrame(xxx) that cuts audio as well?
FlimsyFeet
23rd September 2005, 08:31
I have a capture from a low-quality VHS tape made with VirtualDub where the "dropped frames" are actually duplicate frames in the video.
If I delete these frames within an AviSynth script I get smoother motion, however I've just realised that because there are about 30 frames in total and the audio was in sync before it now drifts off, because deleteframe(xxxx) doesn't delete a frame's length of audio.
I can use VirtualDub to remove these frames and save out the audio separately, but I've already typed all the frame numbers into my script. Is there a quick replacement for the deleteframe command that deals with the audio as well?
midnightsun
23rd September 2005, 08:46
If I understand correctly what will do for you is the trim command
trim(a,b)+trim(c,d)+.... will give you the frames [a,b] and [c,d] deleting everything outside the specified ranges.
The ranges' boundaries (e.g. a,b,c,d,....) are included and audio is trimmed along with video.
FlimsyFeet
23rd September 2005, 09:06
Like this?
function deleteframe2(clip clp, int "framenumber")
{return clp.trim(0,framenumber-1)+trim(framenumber+1,0)}
mg262
23rd September 2005, 09:21
Looks good to me; but why have you put framenumber in quotes?
stephanV
23rd September 2005, 09:29
Is deleting audio really what you want? It will likely produce skips...
FlimsyFeet
23rd September 2005, 09:34
40 millisecond skips in the audio are not noticeable*, but an out-of-syncness of over a second towards the end of the video is!
I put quotes in because I was copying someone else's function syntax. I've not tried it yet because I'm on a different PC.
* Edit - I mean, less noticeable than a repeated frame in the video.
mg262
23rd September 2005, 10:17
(If I remember correctly) quotes make an argument optional... which is not what you want in this case.
You could try replacing the relevant frames with the average of the previous and subsequent frames -- that will probably be less jerky?
stickboy
23rd September 2005, 11:49
Like this?
function deleteframe2(clip clp, int "framenumber")
{return clp.trim(0,framenumber-1)+trim(framenumber+1,0)}Nice try, but it won't work if framenumber is 0 or if framenumber is 1.
Avoid using Trim in user-defined functions! (http://forum.doom9.org/showthread.php?s=&threadid=58358) Try my Trim2 (http://www.avisynth.org/stickboy/) function instead.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.