Thread: Frame rate conversions: How to blend select frames in AVISynth?

1. I'm trying to prepare NTSC film (23.976) footage for PAL (25 fps) playback without resorting to the simple speed-up technique or frame duplication (pulldown). I prefer frame blending in this particular scenario.

AVISynth's ConvertFPS function is blending almost every frame, but I'd like to experiment with blending only two frames each second to maintain the original NTSC running time. Is there a method for blending select frames within AVISynth? Something like blending frame #23 and #24 every 1 second, so that frame #24 becomes #25:
... Fr22 | Fr23 | Fr23+24 | Fr24 ...
2. Try this:
AssumeFPS(24)
c1 = ChangeFPS(25)
c2 = Trim(0,-1)+Trim(1,0).ChangeFPS(25)
Merge(c1,c2)

I think this actually blends frames 0 and 1 in every 24, but the effect is the same.
Since your scheme only makes sense for 24 fps (not 23.976), I've added Assume(FPS(24).
3. This should get you what you want assuming your avi files is progressive.

avisource("progressive24fps.avi")
assumefps(24,1,sync_audio=true)
v1=changeFPS(48)
v2=trim(v1,1,0)
overlay(v1,v2,mode="blend",opacity=0.5)
selectevery(48,0,2,4,6,8,10,12,14,16,18,20,22,24,2 6,28,30,32,34,36,38,40,42,44,46,47)
assumefps(25,1,sync_audio=true)
resampleaudio(44100)
bicubicresize(720,576)

or

avisource("progressive24fps.avi")
assumefps(24,1,sync_audio=true)
v1=changeFPS(48).selectevery(2)
v2=convertFPS(48).selectevery(2,1)
interleave(v1,v2)
selectevery(48,0,2,4,6,8,10,12,14,16,18,20,22,24,2 6,28,30,32,34,36,38,40,42,44,46,47)
assumefps(25,1,sync_audio=true)
resampleaudio(44100)
bicubicresize(720,576)

What these do is double the framerate by duplicating the frames, creating a duplicate clip and offsetting it by 1 frame then overlaying these 2 clips. This produces a clip where one frame is an overlay of the same frame (unblended frame), and the next frame is a blend of two adjacent frames. It then selects 24 of the unblended frames and one of the blended frames giving you 25fps video.
4. Thanks to both of you. Your code examples are very helpful.

The original audio assumes the 23.976 rate, so I'll either have to work in some additional frame correction or resample the audio to run several seconds faster over the course of the entire content (approximately 2 hrs). In this case the speed-up would be only 0.1% !!!
5. My code should take into account the audio changes. That's what the sync_audio=true is for. The first one takes care of the 23.97 to 24 change and the last one takes care of the 24 to 25 change. The resampleaudio just converts it back to a standard samplerate. Put whatever you need in there.
6. Originally Posted by Khaver
My code should take into account the audio changes. That's what the sync_audio=true is for. The first one takes care of the 23.97 to 24 change and the last one takes care of the 24 to 25 change.
That's right, but in fact the second AssumeFPS is redundant in both your scripts as the preceding SelectEvery has already produced a framerate of 25fps.

There was a slight bug in my version. Here is a correction, incorporating audio speedup similar to Khaver.

AssumeFPS(24, sync_audio=true).ResampleAudio(AudioRate())
c1 = ChangeFPS(25)
c2 = Trim(0,-1).AssumeFPS(25)+Trim(1,0).ChangeFPS(25)
Merge(c1,c2)
7. Originally Posted by SDeC
I'm trying to prepare NTSC film (23.976) footage for PAL (25 fps) playback without resorting to the simple speed-up technique or frame duplication (pulldown).
DGPulldown doesn't duplicate one frame every second but 2 fields every second, resulting in smoother playback. And in my opinion the result will look better than will adding a blurred frame every second which will result in an unnatural looking 'strobing' effect.
8. Originally Posted by manono
DGPulldown doesn't duplicate one frame every second but 2 fields every second, resulting in smoother playback. And in my opinion the result will look better than will adding a blurred frame every second which will result in an unnatural looking 'strobing' effect.
DGPulldown was my first method (23.976 > 25), and the results did not look better. I was seeing a 2-jerk/sec effect, which looks terrrible on panning shots and closing credits. It actually looks worse in my opinion than the typical pulldown effect we see on NTSC DVDs.

You're assuming the single blend frame will produce some monstruous blurr every second. It does not. Most of the blend frames throughout the movie are undetectable. Or lets just say, the frequency of prominent blur artifacts is much, much lower than the frequency of jerks. This alone makes this method worth pursuing.

Thanks again for all the comments and thoughts.
9. Using your expertise and suggestions, here's what I ended up with:

AVISource("progressive_video_23.976.avi", audio=false)

f1=ChangeFPS(24)
f2=Trim(0,-1).AssumeFPS(24)+Trim(1,0).ChangeFPS(24)
Film=Merge(f1,f2)

p1=ChangeFPS(Film,25)
p2=Trim(Film,0,-1).AssumeFPS(25) + Trim(Film,1,0).ChangeFPS(25)
Pal=Merge(p1,p2)

Return Pal
The first section nudges the footage to true film rate, but with the original running time by blending two fames every 1000 frames.
The second section then brings to the footage to PAL rate, but with the original running time.

In the end, the newly converted PAL version presents a running time that is only ~20 msec faster than the NTSC original! This error is less than the duration of a single video frame, so no audio adjustments are need. The original A/V sync is preserved.
10. Originally Posted by SDeC
The first section nudges the footage to true film rate, but with the original running time by blending two fames every 1000 frames.
Hey, that's cool.
You were quicker than me to see that my method actually works for any increase in framerate (up to 2x original). I didn't realise that when I worked it out originally.

Statistics