View Full Version : How to filter interlaced video?
ronnylov
7th August 2002, 12:04
Hi!
I want some ideas how to get the best quality when filtering interlaced video and keep it interlaced. My idea is to convert my 25 Hz interlaced video to 50 Hz progressive video before appying the filters and then convert it back to 25 Hz interlaced again.
To keep as much temporal and spatial information as possible I wonder if Donald Graft's Smart Bob filter is the best choise? Can this filter be used in avisynth or is there similar methods with the avisynth commands?
So after converting 25 Hz 720x576 interlaced to 720x576 progressive I apply som noise filters. I guess I can try the convolution3D filter here or perhaps MAM. After completed filtering I want to convert it back to interlaced by discarding all the interpolated field lines and keep the best quality fields and weave them to 25 Hz interlaced with correct field order. I also would like to do some cropping and resizing, add black borders and then encode it to mpeg-2 and put it on DVD-R.
I want the best quality out of TV-captures and DV-captures and keep it interlaced to play it on my standalone DVD player and displayed on a TV.
What do you think about this method? Is there any better or easier way to do this?
Richard Berg
7th August 2002, 12:23
With TV-caps (movies and other film sources excepted) & DV shoots, there's temporal information in the field differences that will be lost if you try to deinterlace. IVTC if appropriate, but otherwise I think you'll be best off just doing a SeparateFields.[insert filters here].Weave
Belgabor
7th August 2002, 12:46
@Richard
I see a small problem with that. If you just separate the fields, the resulting video "wobbles" up & down, which would surely interfere with temporal filtering, so i'd say the following would be better:
a = SeparateFields()
b = a.SelectEven().[Filters]
c = a.SelectOdd().[Filters]
Though i must admit my knowldge about avisynth fails me at that point on how to put it together again ^^'
EDIT: On second thought, perhaps the following works:
AVISource(...)
[Temporal Filter]
SeparateFields
[Spacial Filter]
Weave
Cheers
Belgabor
Richard Berg
7th August 2002, 12:51
True -- goes without saying you shouldn't run temporal filters on field-based video you plan to recombine (although using a radius of 1 would actually be a nifty if crude way to smooth out some interlace artifacts).
You'd recombine your method with Interleave(b,c).Weave()
hakko504
7th August 2002, 13:10
This is a way to do it featuring GreedyHMA:
LoadPlugin("GreedyHMA.dll")
#
#Load video file:
#
video=AVIsource("file.avi") # or use MPEG2source or...
#
# Smartbob video with Greedy
#
even=video.GreedyHMA(1,0,0,0,0,0,0,0)
odd=video.GreedyHMA(0,0,0,0,0,0,0,0)
Interleave(even,odd)
#
# Now add filtering on your 50fps video
#
[filters]
#
# Recreate 25fps interlaced structure
#
Separatefields().SelectEvery(4,0,3).Weave()
ronnylov
7th August 2002, 13:21
Yes, but if I only separate fields and then do temporal filtering wouldn't I get some errors caused by the top field and bottom field is not properly vertically aligned (some kind of jumping up and down between the frames caused by the half pixel difference)? And if I do spatial filtering isn't it better to be able to use the information in the previous frame if there is no movement between the frames (smart bob filter in virtualdub only interpolate the inserted fields if there is movement, depending on the threshold set, otherwise it use the other field)?
If I do a smart bob and convert to 50 Hz then I wouldn't loose any temporal information, I do not deinterlace. I keep the fields I want and weave it back to interlaced afterwards.
Another idea I have is that I separate the fields into two clips (720x288 25 Hz). One with upper fields only and the other clip with bottom fields only. Apply the filters on each clip (to avoid the vertical jumping effect when using temporal filters) and afterwards weave the two clips back to one interlaced clip.
I think I will loose some vertical resolution if I separate fields, do temporal (and spatial) filtering and them weave them back. By using smart bob perhaps I can get better vertical resolution? But perhaps the difference is too small to be seen? I guess I have to do some tests and judge for myself.
ronnylov
7th August 2002, 13:26
Ooops, did not see all te replys after Richards first one... Yes, this separation of fields Belgabor suggested was what I meant as an alternative.
Richard Berg
7th August 2002, 13:41
I still vote to keep'm separate since that's the way the camera captured them, but why not try both ways and tell us what you think?
ronnylov
7th August 2002, 16:36
Do the normal temporal filters only filter one pixel at the time (only comparing different frames)? And normal spacial filters don't do any temporal smoothing? If that's the case I can try the Belgabor second script:
AVISource(...)
[Temporal Filter]
SeparateFields
[Spacial Filter]
Weave
If I want to try a combined temporal&spatial filter like convolution3d I have to separate the fields into different clips, or smartbob. Then I can try belgabors first script, or hakkos. If I smartbob the clip I guess a true temporal filter will be some kind of spacial filter also because it takes info from other pixels to create the missing pixel in the previous and next frame (at least when there is motion, if it's smart). But spacial filtering at motion may not be bad?
If I want to use the MAM filter perhaps I can do it like this?
AVISource(...)
t=[Temporal Filter]
s=[No filter]
MAM
SeparateFields
s=[Spacial Filter]
t=[No filter]
MAM
Weave
Perhaps I can do some testing this weekend.
Marc FD
7th August 2002, 17:31
>AVISource(...)
>t=[Temporal Filter]
>s=[No filter]
>MAM
>SeparateFields
>s=[Spacial Filter]
>t=[No filter]
>MAM
>Weave
I don't think it's a good idea.
if you want max quality and no ghosting at all you should use only one time MAM. this way it would do the spatial filering with a temporal filtered source.
you could try the following : (or is it what you meant ?)
AVISource(...)
t=[Temporal Filter(s)]
SeparateFields
s=[Spacial Filter(s)].Weave
MAM
And if you're filtering an analog source take a look at Cnr2 :)
hakko504
7th August 2002, 17:55
The first part of my script is a SmartBob!
ronnylov
11th August 2002, 13:32
Yes Hakko you are absolutely correct, it is a very smart bob filter!
I have done some initial tests and your smart bob script gives mych better results for me compared to using Donald Graft's Smart Bob filter in VirtualDub. I've never used GreedyHMA before but I think I'll use it for deinterlacing more now.
It works very well to do the filtering with Hakkos script. I had to modify it a little bit when using DV-Video with bottom field first, otherwise I get choppy playback. I changed it to following:
LoadPlugin("GreedyHMA.dll")
#
#Load video file:
#
video=AVISource("Våren 2002.avi") # or use MPEG2source or...
#
# Smartbob video with Greedy
# Bottom field first (DV-Video)
even=video.GreedyHMA(0,0,0,0,0,0,0,0)
odd=video.GreedyHMA(1,0,0,0,0,0,0,0)
Interleave(even,odd)
#
# Now add filtering on your 50fps video
#
# [filters]
#
# Recreate 25fps interlaced structure
#
Separatefields().SelectEvery(4,0,3).Weave()
Thank's for your help everybody!
ronnylov
11th August 2002, 15:34
I've found this thread which describe how to make 50 fps progressive out of 25 Hz interlaced. The 50 Hz progressive was beutiful! But how do I recreate it to interlaced again? The method above gave a staircase effect in the vertical resolution...
http://forum.doom9.org/showthread.php?s=&threadid=28778&perpage=20&pagenumber=3
Here's my script:
-----------------
# To get 50 fps from 25 fps interlaced
# This script is only for BottomFirst material (DV-Video)
LoadPlugin("D:\Download\Video-verktyg\Avisynth\TomsMoComp\Avisynth\TomsMoComp.dll")
AviSource("Våren 2002.avi")
Bottom=AssumeFrameBased()
Top=Bottom.SeparateFields.Trim(1,0).weave
Interleave(Bottom.TomsMoComp(0,5,0),Top.TomsMoComp(1,5,0))
#
# Now add filtering on your 50fps video
#
LoadPlugin("D:\Download\Video-verktyg\Avisynth\Convolution3D\Convolution3D.dll")
Convolution3d (8, 16, 0)
#
# Recreate 25fps interlaced structure
#
Separatefields().SelectEvery(4,0,3).Weave()
--------------
It's the recreation part that seems wrong.
Any suggestrions?
Original picture:
http://hem.bredband.net/lovron/bilder/Input.gif
Output picture:
http://hem.bredband.net/lovron/bilder/Output.gif
ronnylov
12th August 2002, 16:55
Now I have fixed the problem with my TomsMoComp smart bob filter script. This script works well for filtering interlaced DV-material (bottom field first):
# To get 50 fps from 25 fps interlaced
# This script is only for BottomFirst material (DV-Video)
LoadPlugin("TomsMoComp.dll")
AviSource("Våren 2002.avi")
Bottom=AssumeFrameBased()
Top=Bottom.SeparateFields.Trim(1,0).weave
Interleave(Bottom.TomsMoComp(0,5,0),Top.TomsMoComp(1,5,0))
#
# Now add filtering on your 50fps progressive video
#
LoadPlugin("Convolution3D.dll")
Convolution3d (8, 16, 0)
#
# Recreate 25fps interlaced structure
#
Separatefields().SelectEvery(4,0,2).Weave()
The output frames was identical with the input frames but less noisy. The "staircase" effect disappeared after changing the last line in the script.
Maybe you find this script useful. It can be modified for top-field-first video.
wotef
12th August 2002, 17:16
in your example script, can you please explain why it is necessary to delete the first frame?
also, is the top/bottom field order in the tomsmocomp deinterlacing command designed to prevent bobbing?
ronnylov
13th August 2002, 08:39
Hi wotef!
I found the first part of the script in the thread I linked to. It's tbarry that developed the TomsMoComp that knows how this filter works.
The idea is to convert a 25 fps (PAL) or 30 fps (NTSC) interlaced video clip to a 50 fps (PAL) or 60 fps (NTSC) progressive video clip. TomsMoComps deinterlaces the interlaced frames to progressive frames with full resolution. Deinterlacing only will not double the framerate. You have to create full frames of each field. This is done by creating the first frame by deinterlacing bottom and top fields of original frame 1. The second frame is created by deinterlacing the top field of original frame 1 and the bottom field of original frame 2. Frame 3 is created by top and bottom fields of original frame 2 and so on.
The frames created from fields of different original frames (like top field of frame 1 together with lower field of frame 2) has top field first. That's why these frames are deinterlaced with top field first setting in TomsMoComp. The frames created from the original frames are bottom field first.
When studying the double frame-rate clip I did not notice any vertical wobbling effect so it seems that this is prevented by this method. Of course there was a little bit flimmering but not as much compared to other methods.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.