PDA

View Full Version : Some troubles deinterlacing blended source


patxitron
16th September 2004, 22:42
Hi to all.

Before anything, I'm sorry if my post is difficult to understand. The English is not my maternal language and I am using the translator of Google to help me.

I live in PAL land and I am trying to deinterlace some episodes of a DVD collection (Xena). It seems to me that this one is the typical case of material filmed in 24fps, telecined to NTSC and later converted to PAL.

In the first place I have tried it with Telecide but some times I see discontinuities in the movements (nonpresent in the original one) which had took place due to duplicated frames. In addition, once in a while, also it left one frame with the comb effect.

Later I proved with the last version of restore24. No more comb effect but it continues being frames duplicated in sites such that using Telecide.

They bother to me more the movement discontinuities than blended frames, therefore I have applied a script that applies restore24 and then replaces each repeated frame by a mixture of the previous one and the following one (see at the end of the post).

The problem is that the output of restore24 is 23,976fps and I need it to be 25fps. What deinterlace filter with 25fps ouput is more recommendable in this case?

In addition it would thank you for opinions, critics and suggestions. Specially welcome would be the suggestions that allow me to not blend the frames.

Best regards

EDIT: Changed "exit" by output (google's translator confussion with spanish "salida").

This is my script:

### Set this value to 2/3 of your Systems RAM (I have 768MB)
setmemorymax(512)

#### ensure modifying the paths to your *.AVS and *.DLL files

# load the needed functions
import("C:\Video\Avisynth\restore24.avs")
import("C:\Video\Avisynth\intellibob.avs")

# load the needed plugins
loadplugin("C:\Video\Avisynth\masktools.dll")
loadplugin("C:\Video\Avisynth\tcombmask.dll")
loadplugin("C:\Video\Avisynth\kerneldeint140.dll")
loadplugin("C:\Video\Avisynth\tomsmocomp.dll")
loadplugin("C:\Video\Avisynth\avisynth_c.dll")
loadcplugin("C:\Video\Avisynth\smartdecimate.dll")
loadcplugin("C:\Video\Avisynth\ibob.dll")

mpeg2source("E:\Experimento\Corte\Corte.d2v", idct=5) #P4
ProcesaEpisodio(debug = true)



# Estas funciones complementan a las mostradas en http://forum.doom9.org/showthread.php?threadid=75432
# con una detección-corrección de los "framedrops".

# These functions complement to the mentioned ones in http://forum.doom9.org/showthread.php?threadid=75432
# I have added a detection and correction of framedrops.

# Paramerters:
# lumatresh (float): The luminance change threshold to detect movement (default 0.55)
# TFF (bool): Set to true if source is Top Field First (default true)
# test (bool): Set to true to test the field order
# filter (int): 0=no aditional filtering, 1=undot, 2=undot+deen (default 1)
# debug (bool): Set to true for some debug info

#
#
# Main function
#
#
function ProcesaEpisodio(clip c, float "lumatresh", bool "TFF", bool "test", int "filter", bool "debug") {
FieldTest = default(test, false)
PE_TFF = default(TFF, True)
global PE_debug = default(debug, false)
global PE_lumatresh = default(lumatresh, 0.55)
global PE_previous_hm = False
global PE_filter = default(filter, 1)
c = PE_TFF ? c.AssumeTFF() : c.AssumeBFF()
return FieldTest ? c.doFieldTest() : c.Filtrado_DVD()
}


#
#
# aux functions
#
#
function doFieldTest(clip c) {
return c.SeparateFields()
}

function Filtrado_DVD(clip c) {
LoadPlugin("C:\Video\Avisynth\undot.dll")
LoadPlugin("C:\Video\Avisynth\Deen.dll")
c = c.crop(16, 0, -16, 0)
a2 = c.r24kernelbob() # best blend detection, slow
b2 = c.intellibob() # best resolution as possible gets restored, slow
c = restore24(a2, b2, 2997, 6250)
c = (PE_filter < 1) ? c : c.undot()
c = (PE_filter < 2) ? c : c.Deen("a3d", 1, 4, 6, 2)
c = c.ME()
c = c.AddBorders(16, 0, 16, 0)
return c
}


#
# Motion estimation function.
#
function ME(clip c) {
global meref = c
me1 = c.ScriptClip("decision()")
me2 = me1.FrameEvaluate("global melumap = YDifferenceFromPrevious(meref)")
return me2.FrameEvaluate("global meluman = YDifferenceToNext(meref)")
}


#
# Function that replaces the frame repeated by a mixture of the following one and the previous one.
#
function correct_drop(clip c) {
deleted = c.trim(1,0) # Replace repeated frame with next one
c = deleted.Overlay(c, opacity = 0.5, mode = "blend")
return (PE_debug) ? c.Subtitle("Blended", x = 50, y = 112) : c
}

#
# Function that makes the decision if current frame is a framedrop.
#
function decision(clip c) {
global has_movement = (melumap >= PE_lumatresh) ? True : False
global framedrop = ((!has_movement && meluman >= PE_lumatresh) && PE_previous_hm) ? True : False
global PE_previous_hm = has_movement
c = framedrop ? c.correct_drop() : c
return PE_debug ? c.printdebug() : c
}

function printdebug(clip c) {
c = c.Subtitle("Luma change from previous = " + String(melumap) + " luma change to next = " + String(meluman), x = 50, y = 48)
c = c.Subtitle("has_movement = " + String(has_movement), x = 50, y = 64)
c = c.Subtitle("PE_previous_hm = " + String(PE_previous_hm), x = 50, y = 80)
return c.Subtitle("framedrop = " + String(framedrop), x = 50, y = 96)
}

scharfis_brain
16th September 2004, 22:50
either just speedup the video from 23.976 fps to 25 fps,
telecine the 23.976 fps to 25fps interlaced using this script snipplet:

restore24(a,b,2997,6250)
changefps(50) #NO!!! convertfps here
separatefields().selectevery(4,1,2).weave()

or downscale the video to 704x480 and encode as 23.976 fps progressive NTSC

patxitron
16th September 2004, 23:07
I will try the speedup although I fear that the audio loses the synchrony (I would not like to have to reprocess it).

Thank you very much.

Mug Funky
17th September 2004, 10:22
unfortunately there's not many solutions to the 23.976 to 25 problem.

either speed up (and have to change the audio) or interlace the video (it'll still be slightly jerky), or encode NTSC.

most newer PAL land TVs will handle NTSC input from a standalone or whatever, so it's not much of a problem. plus a 23.976, 480p video will have a much lower bitrate than a 25fps 576i video.