Log in

View Full Version : Advice on deinterlacing mpeg2 needed


alexVS
3rd August 2021, 17:19
Hi!
I'm trying to process hockey video PAL 720x576 25i
file
https://drive.google.com/file/d/1hzdIpyykiqB-DfLKJNGtBItbZ-rOkhnf/view?usp=sharing

My task is to bob deinterlace to 50p, crop black border, and save via virtualdub to uncompressed (lagorith codec) to make some color corrections in adobe premierre, cut parts, save to h264

Usually i just use yadif deinterlacer yadif(mode = 1, order = 1) and it gives good result

It comes out that I receive very bad quality, flickering on every second frame, block, soap.
But it seems to me that source has very decent quality.

This working bad:
LoadPlugin("D:\tools\dgindex\DGDecode.dll")
LoadCplugin("D:\AviSynth 2.5\plugins\Yadif.dll")
DGDecode_mpeg2source("Untitle.d2v")
yadif(1, 1)
crop(30, 12, -16, -20)
lanczosresize(720, 544)
ConvertToYUY2()

directshowsource also doesn't help
I tried TDeint and QTGMC( Preset="slow")
All gives bad result, but that strange I can play this file in Media Player Classic smoothly without flickering and dirty noise

Can you help me with advice?
Thanks in advance for your help!

kedautinh12
3rd August 2021, 17:31
Try

converttoyv16
AssumeTFF()
nnclip=nnedi3(-2)
BWDIF(-2,edeint=nnclip)

https://github.com/Asd-g/AviSynth-BWDIF

Sharc
3rd August 2021, 19:18
Apart from the color mess in the first frames it seems to me that one of the fields has a tilted brightness (Y) dropping from bottom to top of the picture which causes the flicker.
There has been a fix for this some time ago (a script by jagabo in the videohelp forum if I remember this correctly) , but I couldn't find it right now.....

alexVS
4th August 2021, 10:23
Try

converttoyv16
AssumeTFF()
nnclip=nnedi3(-2)
BWDIF(-2,edeint=nnclip)

https://github.com/Asd-g/AviSynth-BWDIF

Is there ready-compiled BWDIF DLL for windows?
I don't know how to compile sources and it looks like it's for linux

Reel.Deel
4th August 2021, 10:31
Is there ready-compiled BWDIF DLL for windows?
I don't know how to compile sources and it looks like it's for linux

Binaries are in the released section: https://github.com/Asd-g/AviSynth-BWDIF/releases

But that script alone will not fix your problems. As Sharc pointed out, there is flickering in the source. In this case every other field has fluctuating levels. One way to do away with that problem is just to simply SelectEven() or SelectOdd, but that method drops half of the frames. Another way is to try to mitigate the flickering, you might be able to find a solution on the forum if you search. I remember coming across a thread with a similar problem and Didée came up with a solution. I quickly searched but did not find it, maybe tomorrow I'll dig deeper.

Sharc
4th August 2021, 10:43
Donald Graft's vdub filter "Deflick.vdf" solves the flicker nicely.
http://rationalqm.us/deflick/flick.html

You can use it in a Avisynth script like
LoadVirtualDubPlugin("path to Deflick.vdf", "DeFlick")
MPEG2Source("Untitle.d2v", cpu=0)
QTGMC() #bob-deinterlace
MCDegrainSharp() #denoise
ConvertToRGB32() #required for VirtualDub filters
DeFlick(0, 12, 0, 256, 0) #the second parameter (12) controls the strength; you may reduce it to say 6
ConvertToYV12() # YV12 for x264 encoding

patul
4th August 2021, 12:18
Probably just the same idea as Sharc's post, but with different filters, since you mentioned bobbing, I remember I found a function written by jagabo long back then, to do 'smart' bob deint using TFM, I think it is useful for your sample and it is not resource hog at all

FFVideoSource("C:\Users\USER\Downloads\Untitle.mpg")

# bob deint
TFMBob()

# deflicking
# http://avisynth.nl/index.php/DeFlicker
Deflicker()

Crop(30, 12, -16, -20)

# remove any residual comb if any
# http://avisynth.nl/index.php/Vinverse
Vinverse()

# reduce horizontal lines
# http://www.avisynth.nl/index.php/DeScratch
TurnLeft()
DeScratch()
TurnRight()

# reduce banding
# http://avisynth.nl/index.php/Neo_f3kdb
neo_f3kdb()
LanczosResize(720, 544)

function TFMBob(clip v)
{
# smart bob deint using TFM
# http://avisynth.nl/index.php/TIVTC/TFM
v.GetParity() ? Interleave(TFM(v, field=1), TFM(v, field=0)) : Interleave(TFM(v, field=0), TFM(v, field=1))
}