Log in

View Full Version : New function: FastPreview


Zarxrax
19th March 2004, 06:03
(Scroll down a couple posts for the function)

For the past 2 hours or so, I've been messing around with avisynth, trying to get a script working, but no matter what combinations of AssumeFPS, ChangeFPS, and SelectEverys that I use, I just can't get it to do what I want.

First I will state the problem that I am trying to solve. I often edit video from full episodes or movies, and I often like to seek through the video to find a specific scene. However this can be very time consuming. What I would like to do, is make avisynth create a video stream wherein each frame is from 1 second intervals in the video. Basically speeding up the video so that it plays 24x faster. I would then output the stream to a series of image files which I can browse through with acdsee or whatever.

Secondly, it would be very useful to have timecodes printed on the frames. I know there is a function to output the frame number, but I can't find any way to output a timecode. Is this possible?

So basically in a nutshell, I need:
- Video speeded up 24x (a video that was originally an hour and a half long would now have a running time of about 4 minutes).
- Only 1 out of every 24 of the original frames are displayed.
- Framerate remains at 24 fps.
- Timecode displayed on frames.

zettai
19th March 2004, 09:27
showsmpte()
selectevery(24, 0)
assumefps(24)

Zarxrax
19th March 2004, 16:30
Well you would think that would work, and I've even tried it already. But it just somehow ends up playing 1 frame every 10 seconds or so. :confused:

Edit: I tried it in virtualdub and it works exactly like I wanted :p
:makes note to self: don't try previewing scripts in MPC.

Zarxrax
19th March 2004, 19:34
Ok, I got my function working how I like it now, so I thought I'd post it up incase its of use to anyone else.

FastPreview v0.01 (http://www4.ncsu.edu/~baclontz/FastPreview_v01.avs)

It is designed to help you watch a video really fast when you are looking for particular scenes in the video. By default, it takes one out of every 24 frames, outputs the frames it takes at a rate of 12fps, reduces the resolution by 2, and displays the timecode and framenumber of the original frame. All of these parameters are adjustable.

If anyone has any further suggestions for it, thinks the defaults should be changed, or knows how to make it faster, feel free to tell me. :)

Oh, and you probably need to actually render the output to a file, as it likely wont play in realtime for you, unless your source was huffyuv or something.

Si
19th March 2004, 21:22
Nice work - minor point- normally people post their scripts here.:)

It makes is easier to discuss when you can view it easily at the same time :)

regards
Simon

Zarxrax
19th March 2004, 21:59
A link is not easy enough? :p

function FastPreview(clip input, int "interval", float "framerate", int "reduceby", bool "time", bool "frame") {

interval = Default(interval, 24) # One frame out of every "interval" is taken.
framerate = Default(framerate, 12) # Framerate of the output.
reduceby = Default(reduceby, 2) # Reduce the size of the video by this factor. Set to 1 for no resize.
time = Default(time, true) # Display timecode on/off
frame = Default(frame, true) # Display frame number on/off

input = input.killaudio().pointresize(width(input)/reduceby,height(input)/reduceby)
input = (time==true) ? input.showsmpte(24) : input
input = (frame==true) ? input.showframenumber() : input
input = input.selectevery(interval, 0).assumefps(framerate)
return input
}

LigH
20th March 2004, 20:23
Nice work!

About the choppy playback: Usually a media player drops (many) frames if the frame server is not able to serve all the frames in time. Especially if the video source needs to decode (e.g. MPEG2Dec), this is quite possible. For a media player, it is very important to play the video in sync to the advancing time, an editor instead may play it slower (if the option "Drop frames if behind" is not checked).

scharfis_brain
20th March 2004, 20:55
Me personally is pressing 'shift' within VDub while scrolling through a video.

Therefore I do not need a special function for previewing

(but that's a matter of personal taste)

Zarxrax
20th March 2004, 22:51
scharfis_brain: While that is a great technique that I often use myself, it's only usefull when your video has keyframes. This script is more for things like DVD, DV, huffyuv, etc.

scharfis_brain
20th March 2004, 23:46
hehe, in this case, I'm using ALT instead of SHIFT...

mf
21st March 2004, 00:16
I stopped using inline AVS to encourage people to use Import() instead of pasting the code into their AVS, and because my scripts became too big :D.

odysseus
23rd May 2004, 19:22
I was sent here from another thread.

This is EXACTLY what I was looking for (except one leeeeetle detail)

Would there be any way to fool VDUB into getting the correct frame #.

This would help because you can do your editing & save the edited settings, then re-open that .vcf with a non-speeded up AVS input file.

stickboy
23rd May 2004, 21:38
No, but why would you want to make edits to such a file? Wouldn't you want your cuts to be more precise?

odysseus
24th May 2004, 01:14
You are correct. I wouldn't want to edit that file as it is now.

If that function reported a fake but accurate number to virtualdub then the edits would be accurate.

The solution is a good one but not perfect.

I'm going to just have 2 virtualdubs open, one for accurate editing, one for the previewing.

Originally posted by stickboy
No, but why would you want to make edits to such a file? Wouldn't you want your cuts to be more precise?

stickboy
24th May 2004, 09:09
Originally posted by odysseus
If that function reported a fake but accurate number to virtualdub then the edits would be accurate.My point is not about accuracy; it's about precision.

If you used the FastPreview script to select, say, 1 out of every 24 frames, and want the frames to have their original numbering, then you could do:
# repeat every frame 24 times
SelectEvery(1,
\ 0, 0, 0, 0,
\ 0, 0, 0, 0,
\ 0, 0, 0, 0,
\ 0, 0, 0, 0,
\ 0, 0, 0, 0,
\ 0, 0, 0, 0)Then if you edited that script in VirtualDub, the frame numbers would match up to the original.

My point, however, is that you're inherently losing precision; if there's a sharp scene change in the middle of a group of 24 frames, you're not going to be able to make a cut exactly on that frame.

The best you can do is to use the frame numbers to give you a ballpark figure of where you want to make the cut, then to load up the original script to figure out the exact frame numbers.

odysseus
24th May 2004, 09:32
I understood your meaning.

But since I've just started to really use avisynth I'm still thinking some magic can be done such that when I want to preview I'm skipping 24 at a time and when I want to cut I (or avisynth) can drop into another mode that profides the needed precision.

Thank you for taking your time to help me understand.