Hello.
Is there a way to loop through frames in a clip in an AviSynth script? Like a "For" or "While" loop structure, but in AVS? If there's no way to loop like this, is there any other way to loop through frames?
+ Reply to Thread
Results 1 to 14 of 14
-
-
-
-
If you don't need to loop infinitely you can just add the clip several times.
WhateverSource()
return(last+last+last+last+last...) -
-
-
Anonymous344Guest
I'm sorry to bump an old thread, but I have a related question. Can one make multiple calls to Loop()?
The first call to Loop() does what I want it to do. The second seems to do nothing.Code:x=whateversource() edit= \ x.Trim(0,40000).Loop(10,25000,25000) ++\ x.Trim(40000,80000) ++\ x.Trim(80000,90000).Loop(10,88000,88000) return edit
-
The output of Trim(80000,90000) is a new 10001 frame clip with frames numbered 0 to 10000 (not the original frame numbers). So you can't loop() frame 88000. You want to Loop(10,8000,8000) -- assuming that was your intent.Code:
x.Trim(80000,90000).Loop(10,88000,88000)
Last edited by jagabo; 25th Apr 2014 at 08:17.
-
Anonymous344Guest
Oh, I understand now! Thanks.
Could I insert Loop() earlier to achieve the same effect?
I suppose I could also loop before trimming.Code:x=whateversource() edit= \ x.Trim(0,40000).Loop(10,25000,25000).Loop(10,88000,88000) ++\ x.Trim(40000,80000) ++\ x.Trim(80000,90000) return edit
Code:x=whateversource() edit= \ x.Trim(0,40000).Loop(10,25000,25000) ++\ x.Trim(40000,80000) ++\ x.Loop(10,88000,88000).Trim(80000,90000) return edit
-
This will have a similar problem. The output of the Trim() is a 40001 frame video. So you can't Loop() frame 88000. Further, the output of the first Loop() has 9 extra frames, so even if your second Loop() was within the trimmed video, you would need to account for the extra 9 frames.
That will work. Except you need to account for the extra 10 frames you added with the Loop(). Ie, as written, you are losing 9 frames at the end of the original video.Last edited by jagabo; 25th Apr 2014 at 09:08.
-
Anonymous344Guest
I really should have thought of that...
That all make sense. I'll have to change the way I think about the frame numbers because I keep thinking of them in terms of the original video, rather than the looped/edited video. It's a problem I have come across in the past when writing scripts with multiple calls to DeleteFrame() and DuplicateFrame(). Thanks again.Further, the output of the first Loop() has 10 extra frames, so even if your second Loop() was within the trimmed video, you would need to account for the extra 10 frames...
...That will work. Except you need to account for the extra 10 frames you added with the Loop(). Ie, as written, you are losing 10 frames at the end of the original video. -
Yes, it's easiest to work from last to first in those circumstances. Ie, if you know you want to delete frames 10, 20 and 30 from the original video:
is much easier than:Code:DeleteFrame(30) DeleteFrame(20) DeleteFrame(10)
Code:DeleteFrame(10) DeleteFrame(19) DeleteFrame(28)
-
Anonymous344Guest
That's a good idea. I guess it would work with the situations I come across, in which my script is more like this.
I usually obviate the confusion by using Trim() instead.Code:WhateverSource() DeleteFrame() DuplicateFrame() DeleteFrame() DuplicateFrame() DeleteFrame()
This gets rid of 1001 and duplicates 2000. Obviously, it's a simple example: my scripts are often long. The advantage to me is that ShowFrameNumber() is applied to the original video, so I can see which frames are being added or omitted when scrolling through the video. I'm sure I'll figure out a way to adopt a similar approach when using Loop().Code:x=WhateverSource() \ .ShowFrameNumber(scroll=true) edit= \ x.Trim(0,1000) ++\ x.Trim(1002,2000) ++ \ x.Trim(2000,1000) ++ \ return edit
Similar Threads
-
Will Avisynth 'Directshowsource' Produce Reduced Quality in Frames Served?
By Chakra in forum Newbie / General discussionsReplies: 4Last Post: 1st Nov 2011, 10:25 -
How to display .png just for (exam 3 seconds or 100 frames) with Avisynth?
By xicudiz in forum EditingReplies: 2Last Post: 9th Apr 2011, 22:41 -
How do you blur selected frames in AVIsynth?
By Nagashi in forum EditingReplies: 4Last Post: 9th Jan 2011, 20:30 -
Avisynth drops blank frames?
By wfael in forum EditingReplies: 3Last Post: 9th Dec 2008, 23:06 -
HDTV to DVD using DGIndex/AviSynth losing frames
By gadgetguy in forum Video ConversionReplies: 13Last Post: 3rd Sep 2008, 17:12



Quote