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.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.