View Full Version : How to convert 15fps to 30fps by duplicating every frame only?


video_magic
26th June 2010, 23:24
I thought it should be an easy task, but from searching and reading all I have found is ways of changing the framerate by blending fields and the like!

I have my video clips from my canon digital camera which mostly have the following properties:

Width : 640 pixels
Height : 480 pixels
Display aspect ratio : 4:3
Frame rate : 15.000 fps
Resolution : 8 bits
Scan type : Progressive

I just want to double the framerate to 30 fps by duplicating every frame, i.e. each frame in the video sequence will have a copy of itself after it. Surely possible with Avisynth or a plugin?

Please tell me what I need to type in my script, or what plugin I might need to get. I only want to duplicate every frame, thanks very much!

Gavino
26th June 2010, 23:27
ChangeFPS(30)

Midzuki
27th June 2010, 00:45
SelectEvery(1,0,0)

thewebchat
27th June 2010, 00:46
Interleave(last, last)

video_magic
27th June 2010, 11:26
Just about to try those methods now, thanks in advance.

Jenyok
27th June 2010, 17:31
And what is about sound ?
I think, only ChangeFPS(30) does sound conversion correctly.
.
I have special avisynth scrips to work with video from photo camera Canon or any others.
Do some changes in my scripts and those scripts will be usefull to you to work with video.
If you want I shall put code of my scripts here, wait your answer.

Gavino
27th June 2010, 18:38
And what is about sound ?
I think, only ChangeFPS(30) does sound conversion correctly.
All three solutions give exactly the same result.
The sound is not touched in any way, since there is no need to do so.

video_magic
28th June 2010, 01:08
I used Changefps as above and it worked exactly as I wanted, thanks all! :) I've just finished the project now.

p.s. I had read through several of the items in Avisynth help before - including 'DuplicateFrame' and Changefps, and the 'select' choices! I would not know that any of them could do what I wanted from just reading the descriptions, or if so what to type.

AlekseiV
29th June 2010, 01:57
I would not know that any of them could do what I wanted from just reading the descriptions, or if so what to type.yes you would, ChangeFPS says it duplicates frames

video_magic
29th June 2010, 02:14
I know what it says because I read it

But it doesn't say (in an easy to understand way) how to control the behaviour of the frame duplication - similarly with talking about 'requesting frames in a linear fashion'.

I.e. a basic user would be left none-the-wiser what code to type in to make each frame in a sequence be followed by a duplicate of its' self. Easy enough when one has asked and been told, but not for the beginner to Avisynth (I did not want to just 'double the framerate' in any way, but needed to do it in the way I specified).

Jenyok
29th June 2010, 08:43
And why do you use 30 FPS instead of standart 25 FPS ?

pandy
29th June 2010, 09:48
And why do you use 30 FPS instead of standart 25 FPS ?

Standard but where? In Russia and Europe 25/50 but in US 30/60 (...+30/60:1001)

video_magic
29th June 2010, 23:30
And why do you use 30 FPS instead of standart 25 FPS ?

Destination is a DVD.

All the clips from the Canon camera were to be made into a DVD for friends, and rather than lose any more quality by resizing (or indeed from 'blending frames' method of changing the framerate) I used addborders to padout from 640 -> 704 (from 640x480 to 704x480), and increase the framerate to 30 (from 15), then used assumefps to output to a fraction slower 29.97fps. The clips are so short (all less than 2 minutes that the audio stays in sync).

NTSC was chosen because it fitted closely to retaining quality from the specs of the source-files. With the help here I made my DVD and it looks nice - thankyou again for the help.

um3k
30th June 2010, 00:14
DVDs have non-square pixels, padding will result in a distorted image. You'll have to resize if you want it to look right.

video_magic
30th June 2010, 01:48
Thanks um3k, everything looks a little 'slimmer' on the DVD compared to the original clips, hower this distortion is not enough to spoil the viewing, and infact in some shots the footage looks more representative of real-life at this aspect-ratio (perhaps correcting something off on the Canon video 4/3?); the picture quality is extremely good and close to indistinguishable from the original, which was my aim.

I appreciate that I would have had to resize if the change in aspect-ratio display did not make for acceptable viewing.

Don't think I have anything more to add as my solution was found, thanks again.

Jenyok
30th June 2010, 06:13
video_magic

This is a code to convert correctly video FPS from 15 fps to 29.970 fps NTSC.
I use this code to convert video from Canon photocamera from 30 fps to 25 fps PAL with following parameters
#
FPS_Numerator = 25
FPS_Denominator = 1
#
multinum = 5 # FPS = FPS * multinum / multiden
multiden = 6 # FPS = 30 * 5 / 6 = 25


# Constants
#
FPS_Numerator = 30000
FPS_Denominator = 1001
#
multinum = 29970 # FPS = FPS * multinum / multiden
multiden = 15000 # FPS = 15 * 29970 / 15000 = 29.970

# Needed loading DLL modules
# Change path to your location of modules
#
LoadPlugIn("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\MVTOOLS-V2_5_10\mvtools2.dll")

#
# code for open source file is here
# work variable is "last"
#

#
# Change 15 FPS to 29.970 FPS NTSC
#
# Constants for MVTools v2
# Some constants can to be changed in tuning script
#
# MSuper()
#
blkh = 16
blkv = 8
pel = 2
levels = 0
sharp = 2
rfilter = 4
isse = true

# MAnalyse()
#
delta = 1
overlap = 4
overlapv = 2
plevel = 2
search = 5
dct = 0
divide = 0
badSAD = 10000
truemotion = true

# MRecalculate()
#
thSAD = 100
smooth = 1
chroma = true

# MFlowFPS()
#
mask = 2 # = 1
ml = 2500
thSCD1 = 100
thSCD2 = 130

# Constants for calculation
#
spar = 30 # parametr ?

# Variables
#
dist_h = int((0.01 * spar * Width(last)) / blkh)
dist_v = int((0.01 * spar * Height(last)) / blkv)
dist = (dist_h > dist_v) ? dist_h : dist_v
dist = (dist > 0) ? dist : 1


# function MSuper(clip, int "hpad", int "vpad", int "pel", int "levels", bool "chroma", \
# int "sharp", int "rfilter", clip "pelclip", bool "isse", bool "planar")
#
super = MSuper(last, \
hpad = blkh, \
vpad = blkv, \
pel = pel, \
levels = levels, \
chroma = true, \
sharp = sharp, \
rfilter = rfilter, \
isse = isse, \
planar = false)

# function MAnalyse(clip super, int "blksize", int "blksizeV", int "level", int "search", int "searchparam", \
# int "pelsearch", bool "isb", int "lambda", bool "chroma", int "delta", bool "truemotion", \
# int "lsad", int "plevel", bool "global", int "pnew", int "pzero", int "pglobal", int "overlap", \
# int "overlapV", string "outfile", int "dct", int "divide", int "sadx264", int "badSAD", \
# int "badrange", bool "isse", int "full", bool "meander", bool "temporal")
#
backward_vec1 = MAnalyse(super, \
blksize = blkh * 2, \
blksizeV = blkv * 2, \
isb = true, \
chroma = chroma, \
delta = delta, \
truemotion = truemotion, \
search = search, \
searchparam = dist, \
plevel = plevel, \
overlap = overlap * 2, \
overlapV = overlapv * 2, \
badSAD = badSAD, \
dct = dct, \
divide = divide, \
isse = isse)

# function MAnalyse(clip super, int "blksize", int "blksizeV", int "level", int "search", int "searchparam", \
# int "pelsearch", bool "isb", int "lambda", bool "chroma", int "delta", bool "truemotion", \
# int "lsad", int "plevel", bool "global", int "pnew", int "pzero", int "pglobal", int "overlap", \
# int "overlapV", string "outfile", int "dct", int "divide", int "sadx264", int "badSAD", \
# int "badrange", bool "isse", int "full", bool "meander", bool "temporal")
#
forward_vec1 = MAnalyse(super, \
blksize = blkh * 2, \
blksizeV = blkv * 2, \
isb = false, \
chroma = chroma, \
delta = delta, \
truemotion = truemotion, \
search = search, \
searchparam = dist, \
plevel = plevel, \
overlap = overlap * 2, \
overlapV = overlapv * 2, \
badSAD = badSAD, \
dct = dct, \
divide = divide, \
isse = isse)

# function MRecalculate(clip super, clip vectors, int "thSAD", int "smooth", int "blksize", int "blksizeV", \
# int "search", int "searchparam", int "lambda", bool "chroma", bool "truemotion", \
# int "pnew", int "overlap", int "overlapV", string "outfile", int "dct", int "divide", \
# int "sadx264", bool "isse")
#
backward_recalc = MRecalculate(super, \
backward_vec1, \
thSAD = thSAD, \
smooth = smooth, \
blksize = blkh, \
blksizev = blkv, \
search = search, \
searchparam = dist, \
chroma = chroma, \
truemotion = truemotion, \
overlap = overlap, \
overlapv = overlapv, \
dct = dct, \
divide = divide, \
isse = isse)

# function MRecalculate(clip super, clip vectors, int "thSAD", int "smooth", int "blksize", int "blksizeV", \
# int "search", int "searchparam", int "lambda", bool "chroma", bool "truemotion", \
# int "pnew", int "overlap", int "overlapV", string "outfile", int "dct", int "divide", \
# int "sadx264", bool "isse")
#
forward_recalc = MRecalculate(super, \
forward_vec1, \
thSAD = thSAD, \
smooth = smooth, \
blksize = blkh, \
blksizev = blkv, \
search = search, \
searchparam = dist, \
chroma = chroma, \
truemotion = truemotion, \
overlap = overlap, \
overlapv = overlapv, \
dct = dct, \
divide = divide, \
isse = isse)

# function MFlowFPS(clip source, clip super, clip mvbw, clip mvfw, int "num", int "den", int "mask", \
# float "ml", bool "blend", int "thSCD1", int "thSCD2", bool "isse", bool "planar")
#
MFlowFps(last, \
super, \
backward_recalc, \
forward_recalc, \
num = int(FramerateNumerator(last) * multinum), \
den = int(FramerateDenominator(last) * multiden), \
mask = mask, \
ml = ml, \
blend = true, \
thSCD1 = thSCD1, \
thSCD2 = thSCD2, \
isse = isse, \
planar = false)

AssumeFPS(FPS_Numerator, FPS_Denominator) # Let's comment this string if video is allready 29.970 FPS


This is additional code to convert MONO sound to pseudo STEREO.
I used this algorithm several times in old films, it is work good and sound is good.


# Convert MONO SOUND to pseudo STEREO
# Original algorithm by Evgeniy Gurovskikh (I am)
# based on physical principles of sound distribution in air and the geometrical sizes
# work variable is "audio"
# output variable is "stereo" for AudioDub() function
#
audio = GetChannel(audio, 1) # Get left channel, sound is MONO
left_channel = audio
right_channel = DelayAudio(audio, 0.0121) # 0.0121 sec (Vsound = 331 m/sec) ~ 4 m between sound sources L and R (standart room size is ~6 m in one size)
left_channel = Normalize(left_channel, 0.99)
right_channel = Normalize(right_channel, 0.99)
left_channel_delay = DelayAudio(left_channel, 0.000755) # 0.000755 sec (Vsound = 331 m/sec) ~ 0.25 m (25 sm) average distance between "ears"
right_channel_delay = DelayAudio(right_channel, -0.000755) # 0.000755 sec (Vsound = 331 m/sec) ~ 0.25 m (25 sm) average distance between "ears"
left_channel = MixAudio(left_channel, right_channel_delay, 0.7, 0.3)
right_channel = MixAudio(right_channel, left_channel_delay, 0.7, 0.3)
stereo = MergeChannels(left_channel, right_channel)
stereo = Normalize(stereo, 0.99)

2Bdecided
30th June 2010, 11:12
I'm glad the OP is happy, but I hope no one finds this thread and uses it thinking it's some kind of recommended work flow for putting square pixel 15fps or 30fps footage onto DVD. Adding borders, rather than resizing, is a very strange choice for 640 > 704!

Sometimes these cameras have some aliasing in their output - it's worth dealing with that. If you're targeting "PAL", you can double the size of the image using nnedi2 twice, and then resize down to 704x576. Slow - compare with a straight resize to see if it's worth it.

When changing framerates, I think you have to weigh up the possible artefacts from mvtools, vs the blending of convertfps, vs the jerkyness of changefps. What looks least bad depends on the footage itself.

Jenyok, for 30fps onto a PAL DVD, I'd go to 50i (via one of the above methods), not 25p. Not sure if you need such a long script for mvtools - how about just...
avisource("whatever.avi")
super = MSuper(pel=2)
backward_vec = MAnalyse(super, isb = true)
forward_vec = MAnalyse(super, isb = false)
MFlowFps(super, backward_vec, forward_vec, num=50, den=1)
assumetff().separatefields().selectevery(4,0,3).weave()

However, for 30fps, I'd make an NTSC DVD if I was sure it would play for everyone. Either 60i (mvtools providing smooth movement) or 30p (original footage). For 15fps, it probably doesn't matter.

mvtools can keep more original frames if the original framerate is a simple fraction of the target framerate. If targeting "NTSC", use something like...
AssumeFPS(15000,1001, sync_audio=true)
SSRC(48000)

If targeting "PAL", check the original framerate is an integer - sometimes it isn't - if not, fix it via
AssumeFPS(15,1, sync_audio=true)
SSRC(48000)

fake stereo from mono can sound very strange if someone plays it over a mono speaker (e.g. old TV, or via RF, or on small PMP speaker etc)

Cheers,
David.