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. |
|
|
Thread Tools | Search this Thread | Display Modes |
17th June 2015, 10:26 | #1 | Link |
Registered User
Join Date: Feb 2014
Posts: 355
|
Seeking Advice To Improve An AviSynth Script For NTSC Simpsons DVDs
Hello and thanks in advance for any help . I'm in the process of encoding my NTSC DVD's of the first ten seasons of the Simpsons and, after seemingly endless trial-and-error, dumb luck, and kind help from various people in various places, I've come to the following script:
Code:
# Set DAR in encoder to 6480 : 4739. The following line is for automatic signalling global MeGUI_darx = 6480 global MeGUI_dary = 4739 SetMemoryMax(256) SetMTMode(3,3) LoadPlugin("F:\[0]StandAloneApps\MeGUI-2500(core)2443(data)0.3.5(libs)[Portable]\tools\ffms\ffms2.dll") FFVideoSource("SourcePath", fpsnum=30000, fpsden=1001, threads=1) ### Deinterlace ### SetMTMode(5) LoadPlugin("F:\[0]StandAloneApps\MeGUI-2500(core)2443(data)0.3.5(libs)[Portable]\tools\avisynth_plugin\TIVTC.dll") TFM(Order=-1,Slow=2,PP=0).TDecimate(Mode=1) SetMTMode(2) Vinverse() ### Deshaker ### Stab(Mirror=15) ### Crop ### Crop(8,0,-8,0) ### Resize ### RatioResize(10/11.0,"PAR") ### Gibbs Noise Block ### Edge=MT_Edge("prewitt",thY1=20,thY2=40).RemoveGrain(17) Mask=MT_Logic(Edge.MT_Expand().MT_Expand().MT_Expand().MT_Expand(),Edge.MT_Inflate().MT_Inpand(),"xor") MT_Merge(dfttest(),Mask,Luma=True) ### Overall Temporal Denoise ### SMDegrain(tr=2,thSAD=600,ContraSharp=True,RefineMotion=True,Plane=0,Lsb=True,Lsb_Out=True,PreFilter=2) ### Debanding ### GradFun3(thR=0.55,Radius=12,Mask=2,SMode=1,Lsb=True,Lsb_In=True, StaticNoise=True,Y=3,U=3,V=3) DitherPost(Stacked=True,Prot=False,Mode=0) ### Line Darkener And Thinner ### FastLineDarkenMod(Strength=20,Prot=6,Thinning=0) aWarpSharp2(Blur=4,Type=1,Depth=3,Chroma=2) 1) Is there any reason quality-wise to use DGIndex-M2v instead of FFMSIndex-Mkv? I'm using FFMSIndex because it allows me to utilize AviSynth 2.6 MT; however, I'd switch to DGIndex (and run simultaneous encodes for more production) if it would output higher quality video. 2) Speed not being the main issue is there any way to streamline or amend the above script, any redundancies to rectify, any fat to trim? I'm able to run the script and understand the gist of it, but the finer details are still beyond me (someday ). 3) Looking to that large screen TV, are the x264 settings reasonable or are they overkill? Can they be improved? I can't think of anything else, but I'm sure I will. Thank you for your time, all well-intentioned feedback is much appreciated. Last edited by LouieChuckyMerry; 17th June 2015 at 10:29. Reason: Clarity |
17th June 2015, 13:29 | #3 | Link | |
Useful n00b
Join Date: Jul 2014
Posts: 1,667
|
Quote:
|
|
17th June 2015, 13:55 | #4 | Link | |
Registered User
Join Date: Feb 2014
Posts: 355
|
RatioResize I spent a week testing with AVSMeter (thanks Groucho2004!) and those MT settings are batch-stable and give me the highest fps. Quote:
Thank you . Last edited by LouieChuckyMerry; 17th June 2015 at 13:59. |
|
17th June 2015, 14:35 | #5 | Link |
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
|
When you're doing this:
you probably also want to flag the video stream with "--sar 10:11". You could probably remove a lot of stuff after TDecimate by just using SRestore() (unless you tried this already). Since you are going to encode a lot of episodes I would avoid the AVS MT hassle and potential frustration and encode 2 - 4 (depending on the number of cores of your CPU) episodes simultaneously. Any decent "gui" should offer that feature. If not, use batch files.
__________________
Groucho's Avisynth Stuff Last edited by Groucho2004; 17th June 2015 at 14:44. |
17th June 2015, 15:12 | #6 | Link | |||
Registered User
Join Date: Feb 2014
Posts: 355
|
Quote:
Quote:
Quote:
|
|||
17th June 2015, 15:27 | #7 | Link | ||
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
|
Quote:
Quote:
Having such a complex process run and not crash is one thing. I stopped using AVSMT for "serious" work when I discovered random artefacts at various places in a BD backup. The script only had MDegrain + LSFMod, I used AVSMT to speed it up. I don't know if it was a problem with AVSMT or one of the filters, point is that I only discovered this months later when I watched the backup. Nowadays MT may be more reliable but it's something you have to consider.
__________________
Groucho's Avisynth Stuff |
||
17th June 2015, 22:08 | #8 | Link | |
Registered User
Join Date: Oct 2014
Posts: 476
|
Quote:
10 bit doesn't need dithering. You are converting it to 16 bit color, debanding, using LSB_out to tell gradfun3 not to dither and keep it 16 bit, but then using DitherPost which dithers and converts it to 8 bit... before sending it off to x264 10 bit. Just do your high bit depth color processing last and send it out in 16 bit color with dither_out() and tell x264 what's going on. Add these to your x264 command line with appropriate resolution and FPS: Code:
--demuxer raw --input-depth 16 --input-res 1280x720 --fps 59.97 |
|
18th June 2015, 04:09 | #10 | Link | |||
Registered User
Join Date: Feb 2014
Posts: 355
|
Thanks, I added it.
Quote:
Quote:
Quote:
Code:
--demuxer raw --input-depth 16 --input-res 720x480 --fps 29.970 Last edited by LouieChuckyMerry; 18th June 2015 at 06:08. Reason: Spelling |
|||
18th June 2015, 04:50 | #11 | Link | |
Registered User
Join Date: Oct 2014
Posts: 476
|
Quote:
I don't exactly know where you're converting to 16 bit, though a quick look says it's probably SMDegrain. So you'd end with SMDegrain --> Gradfun3 --> Dither_out() I wouldn't resize back to 720x480 after cropping. There's really no need. Just set the appropriate DAR. Though I don't know how to do that with 16 bit out. I don't know if the MeGUI lines get passed or not. Try it and see. Oh, and it should be 23.97fps after IVTC, no? Last edited by kuchikirukia; 18th June 2015 at 04:53. |
|
18th June 2015, 06:33 | #12 | Link | ||
Registered User
Join Date: Feb 2014
Posts: 355
|
Quote:
Code:
--demuxer raw --input-depth 16 --input-res 640x480 --fps 23.976 Quote:
Code:
### Overall Temporal Denoise ### SMDegrain(tr=2,thSAD=600,ContraSharp=True,RefineMotion=True,Plane=0,Lsb=True,Lsb_Out=True,PreFilter=2) ### Debanding ### GradFun3(thR=0.55,Radius=12,Mask=2,SMode=1,Lsb=True,Lsb_In=True, StaticNoise=True,Y=3,U=3,V=3) Dither_Out() ### Line Darkener And Thinner ### FastLineDarkenMod(Strength=20,Prot=6,Thinning=0) aWarpSharp2(Blur=4,Type=1,Depth=3,Chroma=2) Edit: the above change caused serious flashbacks with MeGUI's preview window, with stacked frames and odd color spaces. Removing "Lsb=True" from GradFun3 eliminated the stacked frames but the color space was still trippy; removing the "Lsb=True" line from GradFun3 and deleting the entire "Dither_Out() resulted in normal looking output, however. EditEdit: seems I typed too soon. The preview window in MeGUI shows normal video with the proper aspect ratio, but the output of a short test clip produces a file with the proper overall aspect ratio but four copies of the video, with the wrong color space, in a grid. Something to do with the command line additions, maybe? Last edited by LouieChuckyMerry; 18th June 2015 at 08:44. |
||
18th June 2015, 16:08 | #13 | Link |
Registered User
Join Date: Oct 2014
Posts: 476
|
Put them last.
(edit: fixed to address the 4-in-one problem below) Code:
# Set DAR in encoder global MeGUI_darx = 628 global MeGUI_dary = 480 SetMemoryMax(256) LoadPlugin("F:\[0]StandAloneApps\MeGUI-2500(core)2443(data)0.3.5(libs)[Portable]\tools\ffms\ffms2.dll") FFVideoSource("SourcePath", fpsnum=30000, fpsden=1001, threads=1) ### Deinterlace ### LoadPlugin("F:\[0]StandAloneApps\MeGUI-2500(core)2443(data)0.3.5(libs)[Portable]\tools\avisynth_plugin\TIVTC.dll") TFM(Order=-1,Slow=2,PP=0).TDecimate(Mode=1) Vinverse() ### Deshaker ### Stab(Mirror=15) ### Crop ### Crop(8,0,-8,0) ### Resize ### ### Gibbs Noise Block ### Edge=MT_Edge("prewitt",thY1=20,thY2=40).RemoveGrain(17) Mask=MT_Logic(Edge.MT_Expand().MT_Expand().MT_Expand().MT_Expand(),Edge.MT_Inflate().MT_Inpand(),"xor") MT_Merge(dfttest(),Mask,Luma=True) ### Line Darkener And Thinner ### FastLineDarkenMod(Strength=20,Prot=6,Thinning=0) aWarpSharp2(Blur=4,Type=1,Depth=3,Chroma=2) ### Overall Temporal Denoise ### SMDegrain(tr=2,thSAD=600,ContraSharp=True,RefineMotion=True,Plane=0,Lsb=True,Lsb_Out=True,PreFilter=2) ### Debanding ### GradFun3(thR=0.55,Radius=12,Mask=2,SMode=1,Lsb=True,Lsb_In=True, StaticNoise=True,Y=3,U=3,V=3) Dither_out() Code:
--demuxer raw --input-depth 16 --input-res 704x480 --fps 23.976 Last edited by kuchikirukia; 19th June 2015 at 21:13. |
19th June 2015, 04:58 | #14 | Link |
Registered User
Join Date: Feb 2014
Posts: 355
|
Thanks for your reply, kuchikirukia. Running a test clip with the suggested script and the suggested command line addition resulted in an output video suffering from four-pictures-in-a-grid-with-trippy-color-space. However, running a test clip with the suggested scrpt but no command line additions resulted in a proper video output. So, it seems that something's wrong with the command line additions. Ahhh, Happy Friday :beer: .
|
19th June 2015, 07:00 | #15 | Link | |
Registered User
Join Date: Jun 2009
Posts: 21
|
Quote:
That's what I use currently (still experimenting a bit over various disc and seasons before a long batch job): First I load stuff. Loading from an remuxed MKV works nicely. No need at all for DGIndex, provides the same result for me. So I went with my selected and configured DirectShow filters here. Code:
DirectShowSource("E:\Encode\S01E01.mkv",audio=false).ConvertToYV12() Code:
Checkmate(thr=10, max=20, tthr2=0) Code:
QTGMC(Preset="medium") #fast should work as well, going slower will produce blended artifacts. SRestore(frate=23.976) Code:
Crop(12,0,-4,-0) # not ITU compliant, more on the left then on the right. Spline36Resize(640,480) Code:
Edge=MT_Edge("prewitt", thY1=20, thY2=40).RemoveGrain(17) Mask=MT_Logic(Edge.MT_Expand().MT_Expand().MT_Expand().MT_Expand(),Edge.MT_Inflate().MT_Inpand(),"xor") MT_Merge(dfttest(), Mask, Luma=True) Code:
Edgecleaner(strength=50) Dehalo_alpha(darkstr=0.5, brightstr=0.5, rx=1, ry=1) The problem is that even after these filters there is noise in the corners left near the black lines and in small areas, that are smudgy on the DVD to begin with. So I stacked the smoothers and added an FFT3D on top. That finally removed all the crap. Now the picture is of course too smooth. So I need to adjust the parameters probably a bit and see if I can get some details out around the edges, areas in general are fine now. Though some "smuge" is left. FFT3D cannot cleanup the picture alone, and neither can Deen. The nice thing is that these stacked combo also took care of the leftover of the Dot Crawl. Code:
FFT3DFilter(sigma=3, bw=32, bh=32, ow=16, oh=16, plane=4) Deen(mode="a2d", rad=4, thrY=7, thrUV=9, min=0.5) FluxSmoothST() Code:
Toon(strength=0.75) Code:
aWarpSharp2(blur=4, type=1, depth=11, chroma=2) Code:
GradFun3(smode=2) Yes, the edges could be a bit more defined and crisper and the picture is very smoothed. But even if you scale it up on a TV to 1080p it is still better then the cropped HD upscales that air for old episodes since some time. If not scaled up the result is more or less like the DVDs should have been in the first place. Will work a bit on the smoothing to lower it. Maybe I'll find a sweet spot. Right now it's a little too much of course, since I stacked filters to get all the noise out. If someone has a suggestion or sees a mistake pls. let me know. And here are some screenshots on a frame with not too much noise on the DVD scaled up to 1080p in the player (so don't mind the jaggies), so you can easily see all the noise. As you see I need still some adjustment with the lines on which I have not yet focussed. http://screenshotcomparison.com/comparison/131783 Edit: Update post Last edited by Scythe42; 19th June 2015 at 22:11. Reason: Updated post. Added Screenshots |
|
19th June 2015, 21:12 | #16 | Link | |
Registered User
Join Date: Oct 2014
Posts: 476
|
Quote:
It's fixed now. Last edited by kuchikirukia; 19th June 2015 at 21:14. |
|
20th June 2015, 03:06 | #17 | Link |
Registered User
Join Date: Jun 2009
Posts: 21
|
So, as the tests for first thin dark lines to get a sharper impression and later thicken them didn't really work out in general as it was too far away from the source. I made some changes:
Here is what is running now over the first seasons and then I check my results and see if something goes really wrong somewhere. Picture is now a bit more smooth compared to before but closer to the original thicker blurry lines. Code:
#Video Source DirectShowSource("E:\Encode\S01E01.mkv",audio=false).ConvertToYV12() #Dot Crawl removal Checkmate(video, thr=10, max=20, tthr2=0) #Deinterlace and Restore QTGMC(Preset="Medium") SRestore(frate=23.976) #Crop and Resize Crop(12,0,-4,-0) Spline36Resize(640,480) #Gibbs Removal Edge=MT_Edge("prewitt", thY1=20, thY2=40).RemoveGrain(17) Mask=MT_Logic(Edge.MT_Expand().MT_Expand().MT_Expand().MT_Expand(),Edge.MT_Inflate().MT_Inpand(),"xor") MT_Merge(dfttest(), Mask, Luma=True) #General Noise Removal FFT3DFilter(sigma=3, bw=32, bh=32, ow=16, oh=16, plane=4) #Edge Cleaning as there is additional noise and halo leftovers Edgecleaner(strength=20) #Temporal Smoothing FluxSmoothST() #Main Smoothing Deen(mode="a2d", rad=4, thrY=7, thrUV=9, min=0.5) #Darken Lines without sharpening to avoid thinning ToonLite(strength=0.75) #Sharpen UnFilter(50, 50) #Color Debanding to get better gradients on larged deblocked areas. GradFun3(video, smode=2) |
20th June 2015, 09:55 | #18 | Link | |
Registered User
Join Date: Feb 2014
Posts: 355
|
Quote:
Code:
# Set DAR in encoder to 6480 : 4739. The following line is for automatic signalling global MeGUI_darx = 6480 global MeGUI_dary = 4739 SetMemoryMax(256) SetMTMode(3,3) LoadPlugin("F:\[0]StandAloneApps\MeGUI-2500(core)2443(data)0.3.5(libs)[Portable]\tools\ffms\ffms2.dll") FFVideoSource("D:\Temp\zSimpTemp\S1.E1-[I-4028].mkv", fpsnum=30000, fpsden=1001, threads=1) ### Deinterlace ### SetMTMode(5) LoadPlugin("F:\[0]StandAloneApps\MeGUI-2500(core)2443(data)0.3.5(libs)[Portable]\tools\avisynth_plugin\TIVTC.dll") TFM(Order=-1,Slow=2,PP=0).TDecimate(Mode=1) SetMTMode(2) Vinverse() ### Deshaker ### Stab(Mirror=15) ### Crop ### Crop(8,0,-8,0) ### Resize ### RatioResize(10/11.0,"PAR") ### Gibbs Noise Block ### Edge=MT_Edge("prewitt",thY1=20,thY2=40).RemoveGrain(17) Mask=MT_Logic(Edge.MT_Expand().MT_Expand().MT_Expand().MT_Expand(),Edge.MT_Inflate().MT_Inpand(),"xor") MT_Merge(dfttest(),Mask,Luma=True) ### Line Darkener And Thinner ### FastLineDarkenMod(Strength=20,Prot=6,Thinning=0) aWarpSharp2(Blur=4,Type=1,Depth=3,Chroma=2) ### Overall Temporal Denoise ### SMDegrain(tr=2,thSAD=600,ContraSharp=True,RefineMotion=True,Plane=0,Lsb=True,Lsb_Out=True,PreFilter=2) ### Debanding ### GradFun3(thR=0.55,Radius=12,Mask=2,SMode=1,Lsb=True,Lsb_In=True, StaticNoise=True,Y=3,U=3,V=3) Dither_Out() Code:
--demuxer raw --input-depth 16 --input-res 640x480 --fps 23.976 --sar 10:11 Thanks for your kind help, kuchikirukia, and a couple more questions if you've time . I remember that the line darkening and thinning was last because that's the usual way (to my understanding). Do you think that this line is now pointless, given that it comes before the denoising-debanding? Or should it be edited or moved? Also, any idea why the aspect ratio according to MediaInfo is 1.212? As I typed above, it displays properly so I reckon that it doesn't rally matter; I just find myself curious. Ahhh, and did I "fix" the 0.683 aspect ratio in a "correct" fashion, or is there a better way? Thanks. Edit: it seems that these lines from MeGUI's "Clever (TM) anamorphic encoding:" setting: Code:
global MeGUI_darx = 6480 global MeGUI_dary = 4739 Scythe42: you may want to reconsider using QTGMC for deinterlacing. When I began this project (seemingly forever ago, ha ha), I asked some questions on the QTGMC thread at Doom9 and was informed that QTGMC is not recommended for animation. Read starting here for details. Also, I take little credit for my script but the results are really good (to my eyes, at least). Start reading here for more information (my Gibb's noise line was born there). Ahhh, thanks for the idea to change my cropping from 8,0,-8,0 to 12,0,-4,0; you're right, the left side is consistently much worse than the right side . Last edited by LouieChuckyMerry; 30th June 2015 at 06:01. Reason: Information, Information |
|
20th June 2015, 13:06 | #19 | Link | |
Registered User
Join Date: Jun 2009
Posts: 21
|
Quote:
Will dive into the fields again and see if I can find an pattern beside a standard IVTC that deals with these frames without making pans choppy by replacing too much or having too much duplicates. Last edited by Scythe42; 21st June 2015 at 06:12. |
|
21st June 2015, 09:08 | #20 | Link | |
Registered User
Join Date: Feb 2014
Posts: 355
|
Quote:
|
|
Thread Tools | Search this Thread |
Display Modes | |
|
|