Log in

View Full Version : How to deinterlace PAL TV recording of a NTSC TV show


sebastiang
26th April 2019, 12:28
How do I properly deinterlace video recorded from PAL DVB-T of a NTSC TV show without ghosting?

Sample: https://mega.nz/#!2BJlyaxJ!fwvqDNLJrRDFpHDUXxax4FY34cKqb1imx24fyuR4qhY

Thank you for help.

manolito
26th April 2019, 17:33
I think the following simple script does a pretty good job on this clip (except for the first couple of frames, but this is probably due to editing a Transport Stream).

DSS2("test.ts")
AssumeTFF()
Yadif(mode=1)
Srestore()

Of course you can use different source filters and a better bobber. And if you need a PAL result you have to speed up the 23.976 frame rate to 25.


Cheers
manolito

sebastiang
26th April 2019, 19:37
Thank you for help, but when I use your script I can still see noticeable ghosting:

https://i.imgur.com/A8aTgfk.png

Sample with this scene: https://mega.nz/#!yQoR3AaZ!EbbopgJDDK-wmz4lwQ4dVpt_Nd4pzGNSfd-u6hCx4cI

Is it possible to get rid of it totally?

manolito
26th April 2019, 20:36
You could play with the Srestore parameters. You should check the double blend removal feature. In another thread I found a post by hello_hello, he used these pasrameters:
SRestore(mode=-1,omode="pp3", thresh=12, speed=-1, cache=10)

Good luck
manolito

FranceBB
29th April 2019, 08:53
Oh God...
You see, those are the bad things of legacy hardware encoders.

https://i.imgur.com/9EV853a.png

When I tried to index it with FFMpegSource2, it reported the wrong framerate as 50fps, while it's really 25i.
LWLibavVideoSource actually got it right as 25i.
When I tried to bob it to get 50fps progressive, I quickly noticed what they have done: blending.

https://i.imgur.com/7or8RVD.png

Basically, I believe that this was originally at a lower framerate (23.976fps I think) and that it has been brutally field blended to 25i. (50fps).

You have three choices:

Choice #1:
You can bob-deinterlace it to 50fps progressive and get it exactly as people saw it on TV when it went on air:


#Indexing
video=LWLibavVideoSource("test.ts")
audio=LWLibavAudioSource("test.ts")
AudioDub(video, audio)

#Bobbing
QTGMC()


If you think that it's too slow, you can try with tdeint:


tdeint(mode=1, order=-1, field=-1, mthreshL=6, mthreshC=6, map=0, type=2, debug=false, mtnmode=1, sharp=true, cthresh=6, blockx=16, blocky=16, chroma=true, MI=64, tryWeave=true, link=1, denoise=true, slow=2, opt=4)


if you still think that it's too slow you can try with Bob:


Bob()



Choice #2:
You can deinterlace it to 25fps progressive and at least get less blending, but it's still gonna be annoying every second:


#Indexing
video=LWLibavVideoSource("test.ts")
audio=LWLibavAudioSource("test.ts")
AudioDub(video, audio)

#Deinterlace
tdeint(mode=2, order=-1, field=-1, mthreshL=6, mthreshC=6, map=0, type=2, debug=false, mtnmode=1, sharp=true, cthresh=6, blockx=16, blocky=16, chroma=true, MI=64, tryWeave=true, link=1, denoise=true, slow=2, opt=4)



Choice #3:
Deinterlace it to 25fps and then use SRestore to try to recover the original 23.976fps. It may not be perfect, but it's worth giving a shot (even though the default parameters fail to properly detect blending in this case, so you are better off with the ones provided by Manolito).



#Indexing
video=LWLibavVideoSource("test.ts")
audio=LWLibavAudioSource("test.ts")
AudioDub(video, audio)

#Deinterlace
tdeint(mode=2, order=-1, field=-1, mthreshL=6, mthreshC=6, map=0, type=2, debug=false, mtnmode=1, sharp=true, cthresh=6, blockx=16, blocky=16, chroma=true, MI=64, tryWeave=true, link=1, denoise=true, slow=2, opt=4)

#Decimating
SRestore(frate=23.976)


By the way, for this kind of interlaced .ts sources, one of the best indexers is DGDecode.

https://i.imgur.com/AHtx0gI.png


Choose your preferred option.
If you ask me, I would bob it to 50fps and stick with blending as it's not too painful to watch or better still, keep it interlaced while re-encoding it.
As to the problem you've got in your screenshot, that's only because of screwed up fields that have been improperly deinterlaced; I bet that DirectShowSource fucked up while decoding it (and if you drop something in an interlaced source, that's what happens).

Cheers,
Frank.

poisondeathray
1st May 2019, 02:15
Choice #3:
Deinterlace it to 25fps and then use SRestore to try to recover the original 23.976fps.

You have to double rate deinterlace (to 50fps in this case) for srestore to work correctly . It has to choose from the remaining blends . If you discard 1/2 of them before it chooses, it won't make the correct choice

It works ok a good source filter is used (not directshow) . But there is a slight blend when a cleaner frame could have been chosen on the screenshot in post#3 using default settings. Perhaps settings could be tweaked, or manual override could be specified. But it's hardly noticable during playback since it's right before the scene change


As to the problem you've got in your screenshot, that's only because of screwed up fields that have been improperly deinterlaced; I bet that DirectShowSource fucked up while decoding it (and if you drop something in an interlaced source, that's what happens).

Yes, post #3 is most likely a directshow decoding problem

sebastiang
3rd May 2019, 12:04
Thank you guys for help!

Yes, post #3 is most likely a directshow decoding problem

I was actually using DGIndexNV and DGSource there.

hello_hello
3rd May 2019, 19:39
Maybe try the another indexer/decoder, because it looks fine here.

LWLibavVideoSource("D:\ghost.ts.lwi")
Yadif(mode=1)
SRestore()
Info()

https://i.postimg.cc/TLD2hmDB/srestore.jpg (https://postimg.cc/TLD2hmDB)

sebastiang
24th May 2019, 11:12
Thank you for help, but when I use your script I can still see noticeable ghosting:

https://i.imgur.com/A8aTgfk.png

Sample with this scene: https://mega.nz/#!yQoR3AaZ!EbbopgJDDK-wmz4lwQ4dVpt_Nd4pzGNSfd-u6hCx4cI

Is it possible to get rid of it totally?

It wasn't DGIndexNVs fault, it was me being stupid (deinterlacing after resizing... :stupid:)

I'm currently messing with QTGMC, but I'm getting low fps and I don't know if I should tune QTGMC or just wait. Is there much difference between QTGMC presets for SD content?

My script: (don't know if I choose right MT parameters, I'm getting 100% CPU usage on my i7 2600)
SetMTMode(5, 8)
SetMemoryMax(1024)
LoadPlugin("E:\DVBT\Megui\tools\dgindexnv\DGDecodeNV.dll")
DGSource("I:\tmp\DVBT\vip\S03E18 - TV6-21052019-1054_cut.dgi")
SetMTMode(2)
QTGMC(Preset="Slower", EdiThreads=4)
SRestore()
crop(4, 10, 0, 0)
Spline36Resize(640,462) # Spline36 (Neutral)

With x264 settings:
x264.exe "script.avs" --level 4.1 --preset veryslow --tune film --crf 21.0 --vbv-bufsize 78125 --vbv-maxrate 62500 -o asd.264
I'm getting ~12fps, with:
x264.exe "script.avs" --level 4.1 --preset ultrafast --tune film --crf 21.0 --vbv-bufsize 78125 --vbv-maxrate 62500 -o asd.264 ~19fps, so I guess QTGMC is the bottleneck. With same x264 settings, but QTGMC preset Slow I get ~30fps.

Is there something else I could tweak to get more fps? Maybe MT parameters? Thanks for help.

EDIT:
I don't know why, but I get much less ghosting when using Yadifmod2(mode=1, order=1)+SRestore, than QTGMC+SRestore, for example:
Frame after frame: (QTGMC)
https://i.imgur.com/Bd6N27i.png
https://i.imgur.com/Ofh2M1N.png
https://i.imgur.com/sdgXoBn.png
https://i.imgur.com/pXqWQD6.png
https://i.imgur.com/7ObfERz.png


Frame after frame: (Yadifmod2)
https://i.imgur.com/syufrdT.png
https://i.imgur.com/QQYENVB.png
https://i.imgur.com/Yw7FacW.png
https://i.imgur.com/OJgRBwP.png
https://i.imgur.com/AhpnAmO.png

What am I doing wrong?

manolito
25th May 2019, 20:43
Is there something else I could tweak to get more fps? Maybe MT parameters? Thanks for help.

EDIT:
I don't know why, but I get much less ghosting when using Yadifmod2(mode=1, order=1)+SRestore, than QTGMC+SRestore, for example:

Whenever I feel that QTGMC is too slow I use a script which was recommended by tritical himself after I asked him what would give me the best quality vs speed ratio (i.e. bang for the buck).


AssumeTFF() # Specify source field order
PointResize(width,height+8,0,-4,width,height+8)
yadifmod(mode=1, edeint=tdeint(mode=1, mthreshL=0,mthreshC=0))
Crop(0,4,-0,-4)
AssumeTFF() # Specify target field order
Srestore()


It is quite fast, and IMO the quality is a lot better than using YADIF by itself. It uses TDeint as the interpolator for YadifMod, plus it it uses padding (thanks to Didée).


Cheers
manolito

sebastiang
29th May 2019, 21:02
Thanks for help, with this script I'm getting ~20fps and results are great, but out of curiosity, why padding is used?

manolito
29th May 2019, 23:21
Padding removes the blinking lines at the top and the bottom of a clip when using YADIF as a bobber. See this thread:
https://forum.doom9.org/showthread.php?p=1325574#post1325574

sebastiang
31st May 2019, 11:47
I want to give QTGMC a try, but I can't get rid of ghosts. Why am I getting them in the encode, even though I don't see any when I preview my script in AvsPmod? Example, same frame: (screeshots from AvsPmod)
SetMTMode(5, 8)
SetMemoryMax(1324)
LoadPlugin("E:\DVBT\Megui\tools\dgindexnv\DGDecodeNV.dll")
DGSource("I:\tmp\DVBT\vip\TV6-29052019-1054_cut.dgi")
AssumeTFF()
SetMTMode(2)
QTGMC()
AssumeTFF()
SRestore()
crop(6, 10, 0, 0)
Spline36Resize(640,464)
https://i.imgur.com/8zHxSrH.png
LoadPlugin("E:\DVBT\Megui\tools\dgindexnv\DGDecodeNV.dll")
DGSource("I:\tmp\DVBT\vip\encode.dgi")
https://i.imgur.com/ssOiqVe.png

What am I doing wrong? :confused:

manono
1st June 2019, 21:13
Why the two AssumeTFF calls? Do you need them? (I haven't looked at the sample.)

manolito
2nd June 2019, 02:01
I think the two AssumeTFF() calls come from my example script...
The first one makes sure that the bobber gets the correct source field order from AviSynth, and the second call is not needed in this case (but I think it also does no harm).

It is a leftover from my standard conversion script which reinterlaces after resizing.
AssumeTFF() # Specify target field order
SeparateFields()
SelectEvery(4,0,3)
Weave()
Specifying the target field order before reinterlacing makes it possible to always use "SelectEvery(4,0,3)" which is much less error prone than using different params for SelectEvery.


Cheers
manolito

manono
3rd June 2019, 03:48
What am I doing wrong? :confused:
Maybe nothing. SRestore needs some time to lock in the cadence so you have to kind of 'sneak up' on the place you really want to check.

If you begin maybe a hundred frames back, are those trees still ghosted? Alternatively, have you actually encoded it yet and found problems afterwards? It probably won't be perfect, especially at scene changes. Blame the geniuses that created the abomination.