Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can simulate the other framerates. For example, if you want 30fps stream on a 60fps video, just add each frame twice.

fps=30
while not endOfMyVideo:
    #get the frame to write...
    if fps==60:
        out.write(frame)
    elif fps==30:
        out.write(frame)
        out.write(frame)

For other frame rates you can duplicate only certain frames:

outputframe=0
inputframe=0
factor=videofps/inputfps
while not endOfMyVideo:
    #get the frame to write...
   out.write(frame)
   if outputframe-inputframe>1:
        out.write(frame) //we need to duplicate this frame
        inputframe=inputframe+1
    inputframe=inputframe+1 #get to the next frame
    outputframe=outputframe+factor

This is a simple solution, for better results you might interpolate the subsequent frames.

On the other hand, this will be a "pseudo" framerate, it won't really change the real framerate of the AVI file. So you can't change the framerate of a 30fps avi to 60fps just to add some high quality video (but you can downsample the 60fps video to 30fps by taking every second frame. The code above can be adapted to this situation too.)