From 09c46afad4d4abfd74044f2b33d9f4c3b2858246 Mon Sep 17 00:00:00 2001 From: Jonatan Nilsson Date: Thu, 7 Dec 2023 03:13:55 +0000 Subject: [PATCH] Add script for interlaced footage --- Advanced_Encode_Interlaced.bat | 13 ++++++++++++ Script_Interlaced.ps1 | 39 ++++++++++++++++++++++++++++++++++ template_interlaced.vpy | 33 ++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 Advanced_Encode_Interlaced.bat create mode 100644 Script_Interlaced.ps1 create mode 100644 template_interlaced.vpy diff --git a/Advanced_Encode_Interlaced.bat b/Advanced_Encode_Interlaced.bat new file mode 100644 index 0000000..cbcbdde --- /dev/null +++ b/Advanced_Encode_Interlaced.bat @@ -0,0 +1,13 @@ +@ECHO OFF +REM TestWrapper.bat +cd /D "%~dp0" +SET args='%1' +:More +SHIFT +IF '%1' == '' GOTO Done +SET args=%args%,'%1' +GOTO More +:Done +Powershell.exe -noprofile -command "& {.\Script_Interlaced.ps1 %args%}" +pause +exit \ No newline at end of file diff --git a/Script_Interlaced.ps1 b/Script_Interlaced.ps1 new file mode 100644 index 0000000..4cbae7d --- /dev/null +++ b/Script_Interlaced.ps1 @@ -0,0 +1,39 @@ +param ( [string[]] $Paths ) + +Write-Host "" + +cd Programs + +$Paths | foreach { + $Path = $_ + + $WithoutExtension = [IO.Path]::ChangeExtension($Path, '') + + $ScriptFile = $WithoutExtension + "script.vpy" + $ArchiveFile = $WithoutExtension + "archive.mkv" + + Write-Host "===============================================================================" + Write-Host "" + Write-Host " Input video: $Path" + Write-Host " Script file: $ScriptFile" + Write-Host " Output video: $ArchiveFile" + Write-Host "" + Write-Host "" + + (Get-Content ..\template_interlaced.vpy).replace('[INPUTFILE]', $Path.replace('\', '/')) | Set-Content -LiteralPath "$ScriptFile" + + .\ffmpeg.exe -hide_banner -y -f vapoursynth -i "$ScriptFile" -i "$Path" -map 0:v:0 -map 1:a:0 -c:v libx265 -profile:v main10 -crf 17.4 -x265-params "me=star:subme=5:limit-modes=1:rect=1:amp=1:max-merge=5:no-early-skip=1:bframes=16:ref=6:rc-lookahead=60:limit-refs=0:rd=6:rdoq-level=2:psy-rdoq=1.00:sao=0" -c:a copy "$ArchiveFile" + + Remove-Item $ScriptFile + Remove-Item "$($Path).lwi" + + cd .. + + .\Script_Web.ps1 "$ArchiveFile" + + cd Programs + + Write-Host "===============================================================================" +} + +cd .. diff --git a/template_interlaced.vpy b/template_interlaced.vpy new file mode 100644 index 0000000..46d8a8f --- /dev/null +++ b/template_interlaced.vpy @@ -0,0 +1,33 @@ +import vapoursynth as vs +core = vs.core +import havsfunc + +clip = core.lsmas.LWLibavSource(source="[INPUTFILE]") + +clip = havsfunc.QTGMC(Input=clip, Preset="Slow", InputType=0, TFF=True, FPSDivisor=1, TR2=2, Sharpness=0.3, SourceMatch=1, Lossless=2, MatchPreset="Slow", MatchPreset2="Slow") + +clip = core.resize.Spline36(clip, format=vs.YUV420P10) + +compSharp = core.cas.CAS(clip, sharpness=0.2) # Sharpen clip for non-shown motion compensated frames, helps retain higher frequency detail at the expense of denoise strength + +super = core.mv.Super(clip, hpad=16, vpad=16, rfilter=4) # all levels for MAnalyse +superSharp = core.mv.Super(compSharp, hpad=16, vpad=16, rfilter=4) # all levels for MAnalyse + +backward2 = core.mv.Analyse(super, isb=True, blksize=16, overlap=8, delta=2, search=3, dct=6) +backward = core.mv.Analyse(super, isb=True, blksize=16, overlap=8, search=3, dct=6) +forward = core.mv.Analyse(super, isb=False, blksize=16, overlap=8, search=3, dct=6) +forward2 = core.mv.Analyse(super, isb=False, blksize=16, overlap=8, delta=2, search=3, dct=6) + +backward2 = core.mv.Recalculate(super, backward2, blksize=8, overlap=4, search=3, divide=2, dct=6) # Optionally Recalculate for higher consistency / quality +backward = core.mv.Recalculate(super, backward, blksize=8, overlap=4, search=3, divide=2, dct=6) +forward = core.mv.Recalculate(super, forward, blksize=8, overlap=4, search=3, divide=2, dct=6) +forward2 = core.mv.Recalculate(super, forward2, blksize=8, overlap=4, search=3, divide=2, dct=6) + +backward_re2 = core.mv.Finest(backward2) +backward_re = core.mv.Finest(backward) +forward_re = core.mv.Finest(forward) +forward_re2 = core.mv.Finest(forward2) + +clip = core.mv.Degrain2(clip, superSharp, backward_re, forward_re, backward_re2, forward_re2, thsad=220, thscd1=300) + +clip.set_output(0) \ No newline at end of file