AfterDawn.com

Changing Framerate



Some video applications require video with a specific framerate. If your clip has a different framerate than what you need you can use AviSynth filters to accomplish it. These filters are particularly useful for converting PAL video to NTSC or vice versa.




ConvertFPS


ConvertFPS(clip Clip, clip Clip2, float new_rate, int numerator, int denominator,
string preset name for ratio, int "zone", int "vbi")

ArgumentTypeDefaultReqDescription
ClipCliplastClip to adjust the framerate
Clip2ClipClip with desired target framerate
new_rateFloating Point DecimalNew framerate
numeratorPositive IntegerNumerator for framerate ratio
denominatorPositive IntegerDenominator for framerate ratio
preset name for ratioStringPreset name for ratio
"zone"Positive IntegerLine to start blending in Switch Mode
"vbi"IntegerVertical Blanking Interval for Switch Mode


ConvertFPS changes the framerate of your clip by adding or removing frames as necessary. Playback speed is unaffected so audio isn't changed at all, and audio sync shouldn't be altered at all.

New frames are created by blending two adjacent existing frames together. ConvertFPS doesn't take interlacing into account. If your video clip is interlaced you'll need to deinterlace before increasing the framerate using this filter.

Clip2
Rather than setting the framerate manually, you may prefer to have AviSynth look at an existing clip instead. Specifying Clip2 will do just that.

new_rate
Use this argument to specify the framerate as the number of frames per second (fps) in decimal form. Standard framerates include 25 (PAL), 29.97 (NTSC), and 23.976 (NTSC film). Other framerates may also be used.

numerator
framerates are normally written as decimals, such as 29.97fps or 23.976fps, the standards actually call for ratios, like 30000/1001 (29.97) or 24000/1001 (23.976). While they may be indistuingishable from each other to the human eye, these slight differences can cause other software which expects the correct ratio to have problems. When dealing with NTSC video it's almost always best to use the ratios instead of the nearly equivalent decimals. This argument represents the numerator in the ratio (30000 for NTSC or 24000 for NTSC film).

denominator
This is the denominator in a ratio-based framerate. For NTSC or NTSC film it should be 1001. See Numerator (directly above) for more information.

preset name for ratio
Rather than explicitly setting a ratio for your target framerate, you can use a preset that describes it instead. ConvertFPS recognizes the following presets.
numeratordenominator
"ntsc_film"240001001
"ntsc_video"300001001
"ntsc_double"600001001
"ntsc_quad"1200001001
"ntsc_round_film"2997125
"ntsc_round_video"2997100
"ntsc_round_double"299750
"ntsc_round_quad"299725
"film"241
"pal_film"251
"pal_video"251
"pal_double"501
"pal_quad"1001

zone
This argument turns on Switch Mode. Instead of blending entire frames, in Switch Mode ConvertFPS will display the top of the first frame, with the middle blended into the second frame, followed by the bottom of the second frame. Zone must be set to a number greater than 0 and less than the horizontal resolution of your video clip.

"vbi"
When you specify the Zone argument you should also set vbi equal to either 49 (for PAL output) or 45 (NTSC output). Vbi is ignored if zone isn't given.

Example Code

Convert interlaced video from PAL to NTSC framerate:
AviSource("SourceClip.avi")
Bob().ConvertFPS("ntsc_double")
SeparateFields().SelectEvery(4,0,3)

Convert NTSC film (23.976fps) video to PAL (25fps) framerate:
Mpeg2Source("SourceClip.d2v")
ConvertFPS(25)

When To Use It

When you want to convert from to a different framerate without adjusting the audio and don't mind blended frames.




changefps


ChangeFPS (clip, float fps, bool "linear")
ChangeFPS (clip, int numerator [, int denominator], bool "linear")
ChangeFPS (clip1, clip2, bool "linear")
ChangeFPS (clip, string preset, bool "linear")

ArgumentTypeDefaultReqDescription
ClipCliplastClip to adjust the framerate
Clip2ClipClip with desired target framerate
fpsFloating Point DecimalNew framerate
numeratorPositive IntegerNumerator for framerate ratio
denominatorPositive IntegerDenominator for framerate ratio
preset name for ratioStringPreset name for ratio
"linear"BooleantrueRequest frames in display order


ChangeFPS changes the framerate of your clip by adding or removing frames as necessary. New frames are duplicates of existing frames in the video. Playback speed is unaffected so audio isn't changed at all, and audio sync shouldn't be altered at all.

Clip2
Rather than setting the framerate manually, you may prefer to have AviSynth look at an existing clip instead. Specifying Clip2 will do just that.

fps
Use this argument to specify the framerate as the number of frames per second (fps) in decimal form. Standard framerates include 25 (PAL), 29.97 (NTSC), and 23.976 (NTSC film). Other framerates may also be used.

numerator
framerates are normally written as decimals, such as 29.97fps or 23.976fps, the standards actually call for ratios, like 30000/1001 (29.97) or 24000/1001 (23.976). While they may be indistuingishable from each other to the human eye, these slight differences can cause other software which expects the correct ratio to have problems. When dealing with NTSC video it's almost always best to use the ratios instead of the nearly equivalent decimals. This argument represents the numerator in the ratio (30000 for NTSC or 24000 for NTSC film).

denominator
This is the denominator in a ratio-based framerate. For NTSC or NTSC film it should be 1001. See Numerator (directly above) for more information.

preset name for ratio
Rather than explicitly setting a ratio for your target framerate, you can use a preset that describes it instead. ChangeFPS recognizes the following presets.
numeratordenominator
"ntsc_film"240001001
"ntsc_video"300001001
"ntsc_double"600001001
"ntsc_quad"1200001001
"ntsc_round_film"2997125
"ntsc_round_video"2997100
"ntsc_round_double"299750
"ntsc_round_quad"299725
"film"241
"pal_film"251
"pal_video"251
"pal_double"501
"pal_quad"1001


Example Code

Convert interlaced video from PAL to NTSC framerate:
AviSource("SourceClip.avi")
Bob().ChangeFPS(preset="ntsc_double")
SeparateFields().SelectEvery(4,0,3)

Convert NTSC film (23.976fps) video to PAL (25fps) framerate:
Mpeg2Source("SourceClip.d2v")
ChangeFPS(25)

When To Use It

When you want to convert from to a different framerate without adjusting the audio and don't want blended frames.





AssumeFPS


AssumeFPS(clip Clip, clip Clip2, float fps, int numerator, int denominator,
string preset, bool "sync_audio")

ArgumentTypeDefaultReqDescription
ClipCliplastClip to speed up or slow down
Clip2ClipClip with desired target framerate
fpsFloating Point DecimalNew framerate
numeratorIntegerNumerator for framerate ratio
denominatorIntegerDenominator for framerate ratio
presetStringStandard framerate preset
"sync_audio"BooleanKeep audio in sync


AssumeFPS changes the framerate of a video clip without adding or removing frames. It simply sets them to play at a different speed. It can also stretch or compress the audio to keep it in sync with the video, although this involves decoding and resampling, which is a lossy process.

Clip2
Rather than setting the framerate manually, you may prefer to have AviSynth look at an existing clip instead. Specifying Clip2 will do just that.

fps
Use this argument to specify the framerate as the number of frames per second (fps) in decimal form. Standard framerates include 25 (PAL), 29.97 (NTSC), and 23.976 (NTSC film). Other framerates may also be used.

numerator
Framerates are normally written as decimals, such as 29.97fps or 23.976fps, the standards actually call for ratios, like 30000/1001 (29.97) or 24000/1001 (23.976). While they may be indistuingishable from each other to the human eye, these slight differences can cause other software which expects the correct ratio to have problems. When dealing with NTSC video it's almost always best to use the ratios instead of the nearly equivalent decimals. This argument represents the numerator in the ratio (30000 for NTSC or 24000 for NTSC film).

denominator
This is the denominator in a ratio-based framerate. For NTSC or NTSC film it should be 1001. See Numerator (directly above) for more information.

preset
Rather than explicitly setting a ratio for your target framerate, you can use a preset that describes it instead. ConvertFPS recognizes the following presets.
numeratordenominator
"ntsc_film"240001001
"ntsc_video"300001001
"ntsc_double"600001001
"ntsc_quad"1200001001
"ntsc_round_film"2997125
"ntsc_round_video"2997100
"ntsc_round_double"299750
"ntsc_round_quad"299725
"film"241
"pal_film"251
"pal_video"251
"pal_double"501
"pal_quad"1001

sync_audio
Setting this to True will keep the audio in sync by resampling it. When you're done you'll usually need to resample the audio to return it to its original samplerate. You can do this with the SSRC filter.

Example Code

Speed up an AVI encoded from DVD from NTSC filme framerate (23.976fps) to PAL framerate:
AviSource("NTSC_film_Source.avi")
AssumeFPS(25, audio_sync=true).SSRC(48000)

Turn NTSC video into slow motion footage:
Mpeg2Source("NTSC_Source.d2v")
AssumeFPS("NTSC_Double")

When To Use It

AssumeFPS is most useful for Changing NTSC film sources to PAL or progressive PAL to NTSC film framerate. It's capability for keeping audio sync is generally only good for two channel audio.
Written by: Rich Fiscus