03-07-2021, 11:48 PM
ragu0012 ragu0012 is offline
Free Member
Join Date: May 2017
Posts: 94
Thanked 6 Times in 4 Posts
I've been chipping away at my project for a few years here now, but I'm always looking for ways to improve my workflow.

For those of you who save two versions of every tape -- interlaced and deinterlaced -- how do you go about it? Do you run two separate scripts from your captured file? Or do you make a deinterlaced version and later go back and run a simple reinterlace script on that lossless version?

I seem to remember Sanlyn writing something about an additional tool he used when reinterlacing beyond just using the SeparateFields().SelectEvery(4,0,3).Weave() command.

Lastly, it is not kosher to run QTGMC on a file then reinterlacing it? Should I be avoiding QTGMC altogether except for my deinterlaced web files?

I feel like I've been wasting a lot of processing time... but here is my "interlaced" script which is pretty much identical to my deinterlaced script with the exception of the Weave command at the end.

SetFilterMTMode("AviSource", 3)

#####-----LOAD A FILE
AviSource("I:\Gail 01.avi")

### / YUY2 -----------------------------
ConvertToYV12(interlaced=true) # script below this line requires YV12

### YV12 Color correction
Tweak(cont=1,sat=1.05, dither=true,coring=false)
Levels(8, 0.9, 250, 16, 255,dither=true,coring=false) 

### ------Deinterlacers
#QTGMC(Preset="Medium", Edithreads=4)

### Final resizers for destination format

# ---------------- reinterlace for DVD ---------------- # 

# ---- Convert 480i to RGB for VirtualDub filters ----- # 

return last
Reply With Quote
Someday, 12:01 PM
admin's Avatar
Ads / Sponsors
Join Date: ∞
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
03-08-2021, 09:22 AM
lollo2 lollo2 is offline
Free Member
Join Date: Mar 2013
Location: Italy
Posts: 632
Thanked 177 Times in 154 Posts
Lastly, it is not kosher to run QTGMC on a file then reinterlacing it? Should I be avoiding QTGMC altogether except for my deinterlaced web files?
It depends on the filter you want to apply on the interlaced material. If you choose a filter designed for progressive video (i.e. TemporalDegrain2 or MCTemporalDenoise), is better to deinterlace, filtering and then interlace back at the end.
QTGMC add its own denoiser, so I prefere to use a pure lossless bobber like "nnedi3(field=-2)".

If you like QTGMC denoise your script is appropriate (QTGMC properly denoise after/while deinterlacing).
Maybe you can try ConvertToYV16 (lossless) instead of ConvertToYV12 if QTGMC does not convert to YV12 internally (I do not remember).
Reply With Quote
03-08-2021, 08:12 PM
keaton keaton is offline
Premium Member
Join Date: Jan 2017
Location: USA
Posts: 163
Thanked 79 Times in 55 Posts
I keep a lossless avi as input, which is the original 29.97 interlaced frames per second (assuming NTSC). It may be a big consumer of space, but if you can afford it and want to be prepared for future changes with new or improved video codecs, you'll have your lossless master to go back to for a re-encode.

An encode to interlaced 29.97 for MPEG-2 or H.264 can be done without QTGMC, if you are only using it to get to the denoiser. Yes, you can do interlaced H.264, it's just not talked about much on the site and some don't suggest it. But I've had success with it and my player was able to deinterlace it properly. I used ffmpeg and included -flags +ildct+ilme in the command line. Picked up the idea from this post http://www.digitalfaq.com/forum/vide...html#post74958

Denoisers may require a progressive source. If so, you can try separating the fields of the existing frames, which are progressive but at half the resolution (either the even 240 rows or the odd 240 rows of a frame), and feed the even and odd fields to the denoiser separately, then weave them back together. That way, you've never technically deinterlaced the video, i.e. an algorithm like QTGMC has not tried to interpolate new data in between the existing even and odd fields of the 29.97 frames per second. An example of how you separate the even and odd fields and then re-interlace them can be seen below.

It may sound that I'm trivializing things by saying you can call the denoiser directly, when i haven't done it myself. But I do believe it is achievable if I had to find out how. You could search the forum or other sites to see how that might be done. I would think somebody has done this before. However, if you do use QTGMC, the frame rate will be doubled. What the SeparateFields().SelectEvery(4,0,3).Weave() call does is for every 4 fields of that 59.94 frames per second output, it takes the first field (top field of frame 1) and the fourth field (bottom field from frame 2) and reinterlaces those into a frame, discarding fields 2 and 3, so the frame rate returns to 29.97 from the 59.94 frame rate that QTGMC generated. Naturally, that is a destructive process. Whether it's acceptable is up to you. It should be encouraged to try things and find out what you prefer. I have learned much from wisdom/experience of others on this forum. However, I ultimately like to come to my own conclusions on things once I understand the fundamentals and do enough trial and error on my own. The main reason I would do that if I had QTGMC output is to make the video compatible for MPEG-2 frame rate of 29.97, or to improve the chances of a video player playing the video successfully if it is H.264. For example, I've seen some video players on TVs that either don't take 59.94 frame rate video at all, or can stutter with it sometimes. If the video has a lot of fast motion where very little data stays the same between frames, you may find things are more degraded than for slower moving video. It depends on what setups you are using. If you find your video players can handle a 59.94 frames per second mp4, for example, my choice would be to leave a deinterlaced video from QTGMC at that frame rate and convert to H.264. That is assuming, of course, you've already made the choice to deinterlace.

A note about QTGMC is that it can effect the levels. If you use avisynth histogram("levels") and look at the Y channel with and without the call to QTGMC, you may see a bit of a change. So, what I do is make the Levels and/or Tweak calls after QTGMC, or any other operation (possibly other denoisers) that can have an effect on the levels so I stay within 16 to 235 on the Y channel (I noticed your example shows a call to Levels using 16 to 255, which I assume was a mistake, as that is out of gamut for YUV video).

In my case, I've been using the RemoveDirtMC.avs script that's been posted by sanlyn, and maybe others, on this forum as a denoiser. I separate the fields and pass them to RemoveDirtMC, then weave the fields back together.

An example:
ConvertToYV16(interlaced=true) # You can use ConvertToYV12(interlaced=true) instead
As lollo2 mentioned, you may try using YV16 instead of YV12, if you are not destined for DVD and are interested in preserving a 4:2:2 color output. I initally had the issue of not being able to use QTGMC or other plugins like RemoveDirtMC without using YV12. But I found it was due to using older versions of plugins. Once I upgraded a few supporting avisynth plugins with recent versions found on avisynth.nl website, I was able to use ConvertToYV16. The dll files I had to update included DePan, DePanEstimate, mvtools2, RgTools, and SmoothUV2. I don't recall at the moment if all of those are needed for QTGMC. I was doing some other things in YV16 as well, so some of those may not be used by QTGMC or RemoveDirtMC.avs
Reply With Quote
03-09-2021, 02:29 AM
lollo2 lollo2 is offline
Free Member
Join Date: Mar 2013
Location: Italy
Posts: 632
Thanked 177 Times in 154 Posts
I keep a lossless avi as input
I do the same, to be prepared for future changes with new or improved video filters ;-)

Denoisers may require a progressive source. If so, you can try separating the fields of the existing frames
The options for filtering interlaced material is the following (the mode X naming is my coding):

Spatial filter:

mode D

Temporal filter:

mode A

mode C
<Bobbing deinterlacer>

Spatial-Temporal filter:

mode B

mode E

mode C
<Bobbing deinterlacer>

Some reference:

That way, you've never technically deinterlaced the video
The same for a Bob lossless deinterlacer

<bob deinterlacer>

is equivalent to


The difference is that the filter works with the double of the data!
Anyhow, even if the operation of deinterlace/reinterlace is not really lossles is not a major problem.

Attached some results of my experiments, to compare the different cases.
Only images, which is not good because motion is important; it is just to give an idea and have your feedbacks. Eventually I can upload the videos.
The filtering on the original (oversharping):

(Note as QTGMC not in lossless mode introduces some defects on the diagonal lines)

I always use mode C for a Spatial-Temporal filter. The problem I face sometimes is that some of my captures are a mixed of interlaced fields and progressive fields; the second only require <filtering> without "deinterlacing", so I have to pay attention at the transitions between the 2 "worlds" and carefully manually choose how to discriminate. Any automatic detection between interlaced/progressive I tried did not satisfy me.








Attached Images
File Type: png ufo_sII2a_spot_amtv_2_cut_step3.png (995.0 KB, 93 downloads)
File Type: png ufo_sII2a_spot_amtv_2_cut_modeA.png (998.4 KB, 81 downloads)
File Type: png ufo_sII2a_spot_amtv_2_cut_modeB.png (1,013.3 KB, 86 downloads)
File Type: png ufo_sII2a_spot_amtv_2_cut_modeC_Bob.png (937.9 KB, 83 downloads)
File Type: png ufo_sII2a_spot_amtv_2_cut_modeC_QTGMC.png (969.4 KB, 3 downloads)
File Type: png ufo_sII2a_spot_amtv_2_cut_modeC_Bob_frame456.png (828.9 KB, 82 downloads)
File Type: png ufo_sII2a_spot_amtv_2_cut_modeC_QTGMC_frame456.png (831.6 KB, 85 downloads)
Reply With Quote
03-27-2021, 06:41 PM
lordsmurf's Avatar
lordsmurf lordsmurf is online now
Site Staff | Video
Join Date: Dec 2002
Posts: 12,161
Thanked 2,246 Times in 1,929 Posts
Reinterlacing video often doesn't work as well as you think it should.

My rule is simple: deinterlace is forever.
Whatever required that deinterlace, be it restoration or distribution, fundamentally changed the video forever. Trying to reinterlace is often like trying to unring a bell.

If you keep an interlaced copy (and you should), it's the last version before deinterlace. Yes, sometimes that means only the unrestored, or partially restored, copy if interlaced. And the fully restored is deinterlaced. Welcome to video.

- Did my advice help you? Then become a Premium Member and support this site.
- For sale in the marketplace: TBCs, workflows, capture cards, VCRs
Reply With Quote
03-27-2021, 07:32 PM
lollo2 lollo2 is offline
Free Member
Join Date: Mar 2013
Location: Italy
Posts: 632
Thanked 177 Times in 154 Posts
That's not true for a lossless "deinterlace"

Attached a comparison of this script:

video_org_sep_tff=video_org.AssumeTFF().separateFi elds()
interlaced=deinterlaced.AssumeTFF().SeparateFields ().SelectEvery(4,0,3).Weave()

### check difference between original video and original video after Nnedi3 and re-interlacing ###
difference_video_org_interlaced=Subtract(video_org , interlaced).Levels(65, 1, 255-64, 0, 255, coring=false)

subtitle(interlaced,"interlaced",size=20,align=2), \
subtitle(difference_video_org_interlaced,"differen ce",size=20,align=2)\


The same with Compare() instead of Subtract()

You must be logged in to view this content; either login or register for the forum. The attached screen shots, before/after images, photos and graphics are created/posted for the benefit of site members. And you are invited to join our digital media community.

In the real life, I do some filtering in between, so it is true that the final video is different, but that's why we do restoration ;-) And I always keep a copy of the raw capture ;-)

Reply With Quote
03-28-2021, 06:44 AM
lollo2 lollo2 is offline
Free Member
Join Date: Mar 2013
Location: Italy
Posts: 632
Thanked 177 Times in 154 Posts

what I do is not a performant deinterlacing, but a step to provide progressive material to the filter to be more effective, and then I re-interlace back because I am not a fan of deinterlacing interlaced videos.

If someone wants to perform the best deinterlancing for whatever reason, will use QTGMC not in lossless mode and never go back, and what stated by lordsmurf applies 100%

Just for clarity

Last edited by lollo2; 03-28-2021 at 07:05 AM.
Reply With Quote

Similar Threads
Thread Thread Starter Forum Replies Last Post
Research paper on CD-DVD optical manufacturing business practices lordsmurf Blank Media 1 11-12-2010 11:45 PM

Thread Tools

All times are GMT -5. The time now is 10:53 AM