Log in

View Full Version : Framerate change with full-frame blending?


Trixter
3rd March 2014, 01:33
I need to lower the framerate of a clip, but instead of simple frame dropping like with selectevery or ChangeFPS, I need the target frames blended. I know that ConvertFPS does this if you stay within a threshold, but I'm going from very high to very low rates (ie. 70fps down to 30 or 24) and ConvertFPS complains and wants me to run in "switch" mode which doesn't produce the same results. What I need is something like, if going from 72 -> 24, each frame in the 24fps output would be the result of three source frames blended together.

Is there a flexible way to do this? By "flexible", I mean for any source framerate? I know that for simple conversions where rates are already known, ie. like 60->30, I can overlay() two clips together that are offset by a single frame, but I have a wide variety of sources that range from even multiples (60fps) to some very odd sources (67fps, 70fps, etc.) and I would really like to avoid writing a new script for each one. (These odd sources really do have unique information in every frame, if you're wondering; they're not misconverted or anything). After Effects can do this but I'd really like to avoid doing that since I have almost 100 clips to convert.

I tried searching the forums and FAQs, but most topics with "frame blending" in them are all about trying to remove frame blending from poor telecine conversions. It's very hard to find info on how to intentionally blend frames.

raffriff42
3rd March 2014, 02:04
By chance I was working on this recently. I find TemporalSoften works well for frame blending in "fast-forward mode," as I like to call it. Here it is, wrapped in a function that handles a wide speed change, with the option to correct audio pitch change or not: #######################################
### change speed over a wide range
### with frame blending in fast forward by default.
##
## @ factor - 0.33 for 1/3 speed, etc;
## min = 0.001; max = min(FrameCount, 1000)
## (if > FrameCount, duration would be 0) ;
## if argument is out of range, an error occurs.
##
## @ pitchfix - if true, maintain audio pitch with speed
## (default false; allow pitch to rise or fall)
##
## @ noblend - if true, never blend frames (default false)
##
## @ raffriff42 24-Feb-2014
##
function UUChangeSpeed2(
\ clip C, float factor,
\ bool "pitchfix", bool "noblend")
{
Assert(factor>=0.001,
\ "UUChangeSpeed2 bad argument: factor<0.001")
Assert(factor<=1000.0,
\ "UUChangeSpeed2 bad argument: factor>1000")
Assert(factor<=C.FrameCount,
\ "UUChangeSpeed2 bad argument: factor>FrameCount")

pitchfix = Default(pitchfix, false)
noblend = Default(noblend, false)

AS = C.AssumeFPS(C.FrameRate * factor)

temprad = Round(0.5 * factor)
TS = (factor<1.0 || temprad==0 || noblend)
\ ? AS
\ : Overlay(
\ AS,
\ AS.TemporalSoften(
\ temprad, 255, 255, 48, 2),
\ opacity=0.7)

(factor<1.5 && noblend==false)
\ ? AS.ConvertFPS(C)
\ : TS.ChangeFPS(C.Framerate, linear=(factor<10.0))

A = (pitchfix)
\ ? C.TimeStretch(tempo=factor*100.0)
\ : C.TimeStretch(rate=factor*100.0)

return (C.HasAudio==false) ? Last : Last.AudioDub(A)
}

ajk
3rd March 2014, 12:48
I tried searching the forums and FAQs, but most topics with "frame blending" in them are all about trying to remove frame blending from poor telecine conversions. It's very hard to find info on how to intentionally blend frames.

There is a BlendFPS() function that allows for any kind of frame rate change. I think it was in the Motion.dll plugin by mg262.

wonkey_monkey
3rd March 2014, 17:26
For your 72->24 example, what about:

convertfps(36)
convertfps(24)

And something similar for other conversions?

Trixter
3rd March 2014, 21:34
All good suggestions that I hadn't considered -- thanks guys! (You'd think this would be a FAQ somewhere)