Log in

View Full Version : Saving specific frames from video


butterw
18th July 2010, 13:32
I need to save specific frames from a video with corresponding hardcoded text.
The text to hardcode contains the framenumber and a specific text (which could be contained in a subtitle file).

I'm not unsure whether avisynth is the right tool to do this ?

Here's what I've come up with:

# This first script basically does what I want, but takes too long time to finish as the video could be several hours long:

AVISource("e:\WEB_0009b.avi", pixel_type="RGB24")
Subtitle( " #000025\n" + " V25 xxxx", lsp=10, first_frame=25, last_frame=25)
Imagewriter("e:\", 25, 25, type="jpg")
Subtitle( " #045000\n" + " V45000 acfdlll", lsp=10, first_frame=45000, last_frame=45000)
Imagewriter("e:\", 45000, 45000, type="jpg")


# To cut down the time required to run the script, it would make sense to select only the frames of interest:

AVISource("E:WEB_0009b.avi", pixel_type="RGB24")
Trim(25,-1) + Trim(45000,-1)
Imagewriter("E:\", type="jpg")

I may have far more than 2 frames to save, so I'm looking for an automated solution. I was thinking of using Python to generate the required avs script.

Any Suggestions ?

Gavino
18th July 2010, 14:47
AVISource("E:WEB_0009b.avi", pixel_type="RGB24")
Trim(25,-1) + Trim(45000,-1)
Imagewriter("E:\", type="jpg")
Note that this one will save the frames in files numbered 0 and 1 (not 25 and 45000) - maybe you don't care about that?

I think you could probably make good use of ConditionalReader (http://avisynth.org/mediawiki/ConditionalReader) for the task of selecting the frames and (if necessary) specifying the text to be written on each (see last example in docs).

um3k
18th July 2010, 15:01
What if he puts the Trims after the Imagewriter call? That would deliver the correct frame numbers, wouldn't it?

Gavino
18th July 2010, 15:31
Yes, you're right, um3k. Smart thinking!