Log in

View Full Version : poor man's 24p


scharfis_brain
16th October 2003, 00:30
I've made a script that converts 60i video to 24p avoiding jerkyness in motion using blending.
since I am a PAL - man I cannot test on a wide spectrum of NTSC - sources.

are there any volunteers, who can do tests with my script?
I think, espessially mode 2 of this script could be useful on non decimateable animes...

usage:
import (convert60ito24p.avs)
loadplugin(your 60fps deinterlacer like dgbob or tomsbob)
xxxsource("clip")
your60fpsdeinterlacer()
convert60ito24p(2,0)

mode - parameter:
------------------
0 uses simple 24 out of 60 selection -> jerky motion

.A B C D E F G H I J K L M N O P Q R <- input sequence
| | | | | | | <- | = direct copy
1 2 3 4 5 6 7 <- resulting output sequence

1 introduces a blending of every other frame from its nearest neighbors

.A B C D E F G H I J K L M N O P Q R <- input sequence
| \ / | \ / | \ / | <- | = direct copy ; \ / = 50:50 blending
1 2 3 4 5 6 7 <- resulting output sequence

this mode delivers a non-jerky motion and should be used with shutter speeds below 1/60sec!
ie. 1/120 or shorter

2 uses blending on every frame like this:

.A B C D E F G H I J K L M N O P Q R <- input sequence
\|/ \ / \|/ \ / \|/ \ / \|/ <- \|/ = 25:50:25 blending ; \ / = 50:50 blending
1 2 3 4 5 6 7 <- resulting output sequence

mode 2 is ideal for shutter speed of 1/60 sec
since it simulates very close the 24p (1/24sec) motion blur
and thus giving a really smooth 24p - motion
as a positive side-effect, this mode reduces noise and nearly comletely
eliminates remained line flickering of the deinterlacing!

every other number given to mode delivers the the input directly to the output (60fps)

offset - parameter:
--------------------
here you can apply a offset for selecting the 2 out of 5 frames - pattern.

function convert60ito24p (clip video, int mode, int offset)
{
work = assumefieldbased(video)

out = (mode==2) ? interleave(
\selectevery(
\layer(trim(work, 1, 0),
\layer(work, trim(work, 2, 0), "fast"),
\"fast"), 5, 0 + offset),
\selectevery(
\layer(work, trim(work, 1, 0), "fast"), 5, 3 + offset)) :

\ (mode==1) ? interleave(
\selectevery(trim(work, 1, 0), 5, 0 + offset),
\selectevery(layer(work, trim(work, 1, 0), "fast"), 5, 3 + offset)) :

\ (mode==0) ? selectevery(work, 5, 1 + offset, 4 + offset) : work

assumeframebased(out)
}

the same post on neuron2.net:
http://neuron2.net/ipw-web/bulletin/bb/viewtopic.php?t=216&highlight=

Mug Funky
16th October 2003, 17:08
hmm. interesting.

i wouldn't think this would work well on anime though... i get enough problems with blended fields to want to create more. but it looks pretty useful for NTSC>>PAL pure video conversion though.

scharfis_brain
16th October 2003, 18:06
but it looks pretty useful for NTSC>>PAL pure video conversion though. with PALspeedup it could work good, I think. But only in the case, where Filmlike motion is wished.

scharfis_brain
17th October 2003, 00:57
I've made a quick'n'dirty website to show my results:
http://home.arcor.de/scharfis_brain/

ltc
28th September 2004, 17:55
Thanks scharfis_brain for the nice conversion routine.
In order to avoid yv12 to yuy2 conversion I modified the function to use overlay instead of layer. It works out fine for me so far however I can't claim to know much avisynth scripting. Let me know if it's good or I screwed up.

Here's the modified routine.

function convert60ito24p (clip video, int mode, int offset)
{
work = assumefieldbased(video)

out =(mode==3) ? interleave(
\selectevery(
\overlay(trim(work, 1, 0),
\overlay(work, trim(work, 2, 0), mode="blend",opacity=0.5),
\mode="blend",opacity=0.5), 5, 0 + offset),
\selectevery(
\overlay(
\overlay(work, trim(work, 3, 0),mode="blend",opacity=0.5),
\overlay(trim(work, 2, 0), trim(work, 1, 0),mode="blend",opacity=0.5),
\level = 170), 5, 2 + offset)) :

\ (mode==2) ? interleave(
\selectevery(
\overlay(trim(work, 1, 0),
\overlay(work, trim(work, 2, 0), mode="blend",opacity=0.5),
\mode="blend",opacity=0.5), 5, 0 + offset),
\selectevery(
\overlay(work, trim(work, 1, 0), mode="blend",opacity=0.5), 5, 3 + offset)) :

\ (mode==1) ? interleave(
\selectevery(trim(work, 1, 0), 5, 0 + offset),
\selectevery(overlay(work, trim(work, 1, 0), mode="blend",opacity=0.5), 5, 3 + offset)) :

\ (mode==0) ? selectevery(work, 5, 1 + offset, 4 + offset) : work

assumeframebased(out)
}


Here's the original downloaded from scharfis_brain

function convert60ito24p (clip video, int mode, int offset)
{
work = assumefieldbased(video)

out =(mode==3) ? interleave(
\selectevery(
\layer(trim(work, 1, 0),
\layer(work, trim(work, 2, 0), "fast"),
\"fast"), 5, 0 + offset),
\selectevery(
\layer(
\layer(work, trim(work, 3, 0),"fast"),
\layer(trim(work, 2, 0), trim(work, 1, 0),"fast"),
\level = 170), 5, 2 + offset)) :

\ (mode==2) ? interleave(
\selectevery(
\layer(trim(work, 1, 0),
\layer(work, trim(work, 2, 0), "fast"),
\"fast"), 5, 0 + offset),
\selectevery(
\layer(work, trim(work, 1, 0), "fast"), 5, 3 + offset)) :

\ (mode==1) ? interleave(
\selectevery(trim(work, 1, 0), 5, 0 + offset),
\selectevery(layer(work, trim(work, 1, 0), "fast"), 5, 3 + offset)) :

\ (mode==0) ? selectevery(work, 5, 1 + offset, 4 + offset) : work

assumeframebased(out)
}