Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 16th June 2022, 14:30   #1  |  Link
jriker1
Registered User
 
Join Date: Dec 2003
Posts: 485
deinterlacing+ not coming out smooth

I have the below script I'm running on some old VHS footage. Footage is 29.97 and interlaced. Final outcome is 59.94 and progressive. The resulting footage doesn't seem super smooth movement wise like the source. Do you see something wrong with this script that would cause movement to be not so smooth and maybe the look of ghosting during movement?

Code:
#LoadPlugin("D:\Program Files (x86)\AviSynth+\plugins+\LSMASHSource.dll")
function VideoAndAudio(string filename)
{
  v = LWLibavVideoSource(filename) # get video
  a = LWLibavAudioSource(filename) # get audio
  AudioDub(v,a) # join them
}


VideoAndAudio("<video>")
assumetff() 
resampleaudio(48000) # audio resampling because my caps are 32khz 
converttoyv12(interlaced=true) 
ylevels(0,1.000,255,16,255) # adjust Luma levels only (adjust according to your needs) 
tweak(sat=1.2,cont=1.0,bright=0,coring=false) # adjust saturation, contrast, etc... 
######################## 
pointresize(last.width, last.height*2).ConverttoRGB32(matrix="rec601",interlaced=true).pointresize(last.width, last.height) 
separatefields() ## Remove some chroma noise with CCD in RGB (gives best results) 
## pointresizing for lossless RGb <> YCrCb convertion 
LoadVirtualDubPlugin("Z:\virtualdub\plugins32\Camcorder_Color_Denoise_sse2.vdf", "CCD", 1) 
CCD(15,1) # from 0 to 100 # Default =30 / 15-30 = best results 
# Sharpening (small-medium) with msu smart sharpen 
LoadVirtualDubPlugin("Z:\virtualdub\plugins32\msu_sharpen.vdf", "MSUSmartSharpen", 1) 
MSUSmartSharpen(3) # from 0 (small overall) to 5 (mad) 
weave() 
pointresize(last.width, last.height*2).converttoyv12(matrix="Rec601",interlaced=true).pointresize(last.width, last.height) 
################### 
# Denoising with Mdegrain1 for not too strong noise and interlaced source 
fields=AssumeTFF().SeparateFields() 
# or AssumeBFF 
super = MSuper(fields) 
backward_vec2 = MAnalyse(super, isb = true, delta = 2, overlap=2) 
forward_vec2 = MAnalyse(super, isb = false, delta = 2, overlap=2) 
MDegrain1(fields, super, backward_vec2,forward_vec2,thSAD=400) 
Weave()


AssumeTFF()

QTGMC(Preset="Slower", SourceMatch=3, Lossless=2, Sharpness=0.1)
Crop(6,0,0,-8)
AddBorders(6,0,0,8)

Last edited by jriker1; 16th June 2022 at 14:58.
jriker1 is offline   Reply With Quote
Old 16th June 2022, 19:31   #2  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
One obvious thing to check is that AssumeTFF is correct. Feed your original to this script:

Separatefields()
AssumeTFF()

and see if you get retrograde motion (two steps forward, one step back). If you do, change to BFF.

I think your PointResize is being done on interlaced footage. Any resizing should be done after the footage is progressive (i.e., at the end) after you apply QTGMC.

Your first set of functions that are applied to separated fields are not preceded by a selecteven() and selectodd() function. Normally you do your processing, after separating fields, on the even fields only and then the odd fields only. Otherwise the adjacent fields are not spatially aligned. You then do an Interleave() command prior to the Weave() command to put the even and odd fields back together. I can't remember if you do Interleave(Even,Odd) or Interleave (Odd,Even). I always have to test this for every script.

You do a second Seperatefields() just after making the video interlaced again. Not sure why you did this. Probably not a big deal, but there is a small possibility that you could have reversed the fields in the previous Weave() statement. I don't think your script will do this, but you can easily check by temporarily making the last statement in the script Return(fields). You can see if you have any retrograde motion.
johnmeyer is offline   Reply With Quote
Old 16th June 2022, 22:36   #3  |  Link
jriker1
Registered User
 
Join Date: Dec 2003
Posts: 485
Thanks for the help I will adjust things accordingly. Other issue I'm running into. So the source video has per mediainfo:

Pixel aspect ratio : 0.889
Display aspect ratio : 1.333
Display aspect ratio : 4:3

However the resulting output video shows

Pixel aspect ratio 1.0
Display aspect ratio 1.5

Is there something I have to add to the script to make sure the PAR and DAR are right? I'm guessing AVISynth isn't responsible for this but would hope that VirtualDub would set these values accurately on output IF LWLibavVideoSource was passing the right info to the encoder but probably inaccurate.

Or maybe I continue working with it the way it is and then when I put the final file in the MKV container add the DAR 1.333 to it?

Last edited by jriker1; 17th June 2022 at 01:02.
jriker1 is offline   Reply With Quote
Old 17th June 2022, 06:43   #4  |  Link
Mounir
Registered User
 
Join Date: Nov 2006
Posts: 773
you forgot selecteven

Quote:
qtgmc()
selecteven() # for 29.97 fps
This is my old script by the way, assuming your source is a lossless avi YUY2 you could get best results like this:

Quote:
VideoAndAudio("<video>")
assumetff()
resampleaudio(48000) # audio resampling because my caps are 32khz
#converttoyv12(interlaced=true) # no convertion yet
ylevels(0,1.000,255,16,255) # adjust Luma levels only (adjust according to your needs)
tweak(sat=1.2,cont=1.0,bright=0,coring=false) # adjust saturation, contrast, etc...
########################
ConverttoRGB32(matrix="rec601",interlaced=true)
separatefields() ## Remove some chroma noise with CCD in RGB (gives best results)
LoadVirtualDubPlugin("Z:\virtualdub\plugins32\Camcorder_Color_Denoise_sse2.vdf", "CCD", 1)
CCD(15,1) # from 0 to 100 # Default =30 / 15-30 = best results
# Sharpening (small-medium) with msu smart sharpen
LoadVirtualDubPlugin("Z:\virtualdub\plugins32\msu_sharpen.vdf", "MSUSmartSharpen", 1)
MSUSmartSharpen(3) # from 0 (small overall) to 5 (mad)
weave()
converttoyv12(matrix="Rec601",interlaced=true)
###################
# Denoising with Mdegrain1 for not too strong noise and interlaced source
fields=AssumeTFF().SeparateFields()
# or AssumeBFF
super = MSuper(fields)
backward_vec2 = MAnalyse(super, isb = true, delta = 2, overlap=2)
forward_vec2 = MAnalyse(super, isb = false, delta = 2, overlap=2)
MDegrain1(fields, super, backward_vec2,forward_vec2,thSAD=400)
Weave()
QTGMC(Preset="Slower", SourceMatch=3, Lossless=2, Sharpness=0.1)
selecteven()
Crop(6,0,0,-8)
AddBorders(6,0,0,8)
a couple remarks: CDD: 15 is high make sure it's what you need (in practice 5-15 for retail vhs )
msu sharp: 3 is high aswell (i like 0 or 1 personnally)
pointresize: no need now, i believe that was because of a mismatch between yv12<> rgb rounding errors, avisynth 2.6 mt fixed it
qtgmc("slower"), by using the "slower" mode you are denoising some more i advise you to use "fast" or "medium"

Last edited by Mounir; 17th June 2022 at 06:48.
Mounir is offline   Reply With Quote
Old 18th June 2022, 00:41   #5  |  Link
jriker1
Registered User
 
Join Date: Dec 2003
Posts: 485
Thanks for the help. Should I be doing selecteven()? Know the source is 29.97 but would 59.94 look any smoother?
jriker1 is offline   Reply With Quote
Old 18th June 2022, 01:12   #6  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
If you're starting out with 29.97 interlaced video, and if you want it to have the same "feel" and smoothness as the original, then my choice would be to leave it as 59.94 progressive. Therefore, I would not use selecteven() at the end.

À chacun son goût.
johnmeyer is offline   Reply With Quote
Old 18th June 2022, 14:34   #7  |  Link
jriker1
Registered User
 
Join Date: Dec 2003
Posts: 485
Thanks. The original VHS was encoded to the following specs, sharing what I assume are relevant so to not post to much detail. Glad to provide the whole MediaInfo output:

Inform: 24.4 Mb/s, 720*480 (4:3), at 29.970 (29970/1000) FPS, DV (NTSC)
Format: DV
Width: 720 pixels
Height: 480 pixels
Pixel aspect ratio: 0.889
Display aspect ratio: 1.333
Display aspect ratio: 4:3
Frame rate: 29.970 (29970/1000) FPS
Color space: YUV
Scan type: Interlaced
Scan order: Bottom Field First

When I run the AVISynth script thru VirtualDub, I end up with:

Inform: 73.2 Mb/s, 720*480 (3:2), at 59.940 (60000/1001) FPS, Lagarith
Format: Lagarith
Width: 720 pixels
Height: 480 pixels
Pixel aspect ratio: 1.000
Display aspect ratio: 1.500
Display aspect ratio: 3:2
Frame rate: 59.940 (60000/1001) FPS
Color space: YUV
Scan Type not listed in output but progressive now


So what happened to the Pixel and Display aspect ratios?

Note this isn't the final output and perhaps when it's in an MKV container I just need to change the DAR or something in the metadata but not sure.
jriker1 is offline   Reply With Quote
Old 18th June 2022, 15:49   #8  |  Link
lollo2
Registered User
 
lollo2's Avatar
 
Join Date: Aug 2017
Location: Italy
Posts: 113
Why applying MDegrain1 on separate fields when finally you deinterlace the video? It is more effective (and technically correct) if used after QTGMC(). And while you are there better keep all frames, rather then removing one with SelectEven() loosing half of the motion, ad johnmeyer properly suggested.
__________________
A channel on S-VHS / VHS capture and AviSynth restoration https://www.youtube.com/channel/UCMs...h1MmNAs7I8nu4g
lollo2 is offline   Reply With Quote
Old 18th June 2022, 16:32   #9  |  Link
jriker1
Registered User
 
Join Date: Dec 2003
Posts: 485
Quote:
Originally Posted by lollo2 View Post
Why applying MDegrain1 on separate fields when finally you deinterlace the video? It is more effective (and technically correct) if used after QTGMC(). And while you are there better keep all frames, rather then removing one with SelectEven() loosing half of the motion, ad johnmeyer properly suggested.
Thanks. I removed SelectEven from the script. With MDegrain1 isn't it better to do this with the original footage than after it's been modified by QTGMC? Just thinking out loud.
jriker1 is offline   Reply With Quote
Old 18th June 2022, 17:37   #10  |  Link
lollo2
Registered User
 
lollo2's Avatar
 
Join Date: Aug 2017
Location: Italy
Posts: 113
The question is that the video is interlaced, and the temporal filters or spatial/temporal filters are designed for progressive frames. If you denoise after SeparateFields() is wrong. If you denoise after SeparateFields() .SelectEven() or SeparateFields().SelectOdd() is not optimal, and somehow wrong as well.

For a pure temporal filter in theory there is no need to deinterlace, neither to do any of the field operation. In practice, working with a deinterlaced frame gives twices the data to the filter, which is better.

Some references:
https://forum.doom9.org/showthread.php?t=86394
http://forum.doom9.net/showthread.ph...93#post1921993
https://forum.doom9.org/showthread.p...95#post1691595
__________________
A channel on S-VHS / VHS capture and AviSynth restoration https://www.youtube.com/channel/UCMs...h1MmNAs7I8nu4g
lollo2 is offline   Reply With Quote
Old 20th June 2022, 14:44   #11  |  Link
jriker1
Registered User
 
Join Date: Dec 2003
Posts: 485
Side item. Do we know why when I run this script thru virtualdub it shows all kinds of white lines?



Picture isn't showing so here is a link: https://ibb.co/f2bGNLQ

This isn't in the source file and doesn't really show in the final output but I have seen it from time to time when scrolling thru the output video.

Note if I strip out everything but the QTGMC part and converttoyv12 it goes away hmmm.

Seems to be related to this piece:

Quote:
converttoyv12(matrix="Rec601",interlaced=true)
###################
# Denoising with Mdegrain1 for not too strong noise and interlaced source
fields=AssumeBFF().SeparateFields()
# or AssumeBFF
super = MSuper(fields)
backward_vec2 = MAnalyse(super, isb = true, delta = 2, overlap=2)
forward_vec2 = MAnalyse(super, isb = false, delta = 2, overlap=2)
MDegrain1(fields, super, backward_vec2,forward_vec2,thSAD=400)
Weave()
Sure not the right answer, but if I add in again:

converttoyv12(matrix="Rec601",interlaced=true)

After the end Weave() again those lines go away. However if I remove the above section entirely except for the converttovy12 lines are still there ugh.

Should note it's flaky. Like I can remove a section and those lines aren't there, then add them back in and "maybe" they will come back maybe they won't.

Like I took out:

Quote:
# Sharpening (small-medium) with msu smart sharpen
LoadVirtualDubPlugin("Z:\virtualdub\plugins32\msu_sharpen.vdf", "MSUSmartSharpen", 1)
MSUSmartSharpen(3) # from 0 (small overall) to 5 (mad)
and they went away. But putting that back in and loading again weren't there. Make other changes or remove and add something else back in and they come back.

Last edited by jriker1; 20th June 2022 at 15:13.
jriker1 is offline   Reply With Quote
Old 20th June 2022, 15:32   #12  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
Quote:
Originally Posted by jriker1 View Post
The original VHS was encoded to the following specs, <snip>
Scan type: Interlaced
Scan order: Bottom Field First
The scan order confirms my original suspicion: your script specifies Top Field First (i.e., AssumeTFF() ). Change that to AssumeBFF().

The rest of your original script will probably be OK (i.e., if you are going to deinterlace, then you WANT to have 59.94 fps progressive as your final output.
johnmeyer is offline   Reply With Quote
Old 20th June 2022, 16:08   #13  |  Link
jriker1
Registered User
 
Join Date: Dec 2003
Posts: 485
Quote:
Originally Posted by johnmeyer View Post
The scan order confirms my original suspicion: your script specifies Top Field First (i.e., AssumeTFF() ). Change that to AssumeBFF().

The rest of your original script will probably be OK (i.e., if you are going to deinterlace, then you WANT to have 59.94 fps progressive as your final output.
I did shortly after asking this question so what you are seeing is with BFF. Movement looked better but I have this issue with white lines. This is my current script that is on and off giving me those white lines:

Quote:
LWLibavVideoSource("<video>")
assumebff()
resampleaudio(48000) # audio resampling because my caps are 32khz
#converttoyv12(interlaced=true) # no convertion yet
ylevels(0,1.000,255,16,255) # adjust Luma levels only (adjust according to your needs)
tweak(sat=1.2,cont=1.0,bright=0,coring=false) # adjust saturation, contrast, etc...
########################
ConverttoRGB32(matrix="rec601",interlaced=true)
separatefields() ## Remove some chroma noise with CCD in RGB (gives best results)
LoadVirtualDubPlugin("Z:\virtualdub\plugins32\Camcorder_Color_Denoise_sse2.vdf", "CCD", 1)
CCD(15,1) # from 0 to 100 # Default =30 / 15-30 = best results
# Sharpening (small-medium) with msu smart sharpen
#LoadVirtualDubPlugin("Z:\virtualdub\plugins32\msu_sharpen.vdf", "MSUSmartSharpen", 1)
#MSUSmartSharpen(3) # from 0 (small overall) to 5 (mad)
weave()
converttoyv12(matrix="Rec601",interlaced=true)
###################
# Denoising with Mdegrain1 for not too strong noise and interlaced source
fields=AssumeBFF().SeparateFields()
# or AssumeBFF
super = MSuper(fields)
backward_vec2 = MAnalyse(super, isb = true, delta = 2, overlap=2)
forward_vec2 = MAnalyse(super, isb = false, delta = 2, overlap=2)
MDegrain1(fields, super, backward_vec2,forward_vec2,thSAD=400)
Weave()
SetFilterMTMode("QTGMC", 2)
QTGMC(Preset="Slower", SourceMatch=3, Lossless=2, Sharpness=0.1, EdiThreads=5)
Prefetch(8)
#selecteven()
Crop(6,0,0,-8)
AddBorders(6,0,0,8)

Last edited by jriker1; 20th June 2022 at 19:19.
jriker1 is offline   Reply With Quote
Old 20th June 2022, 21:26   #14  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
Try a different zoom level in Virtualdub. Depending on your video driver, you can sometimes get artifacts in the VirtualDub display which are not actually in the video. You can also test this idea by rendering 2-3 seconds of video and see if the white lines show up in the final render.
johnmeyer is offline   Reply With Quote
Reply

Tags
avisynth

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 18:24.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.