A collection of macros for AvsPmod.
-
Copy contents of tools folder from this repository to tools folder in AvsPmod.
-
Copy desired macros from macros folder from this repository to macros folder in AvsPmod.
Creates .bat files to encode some part of file again and losslessly splice it into old encode. Only works with mkvtoolnix 7.0.0 or newer.
Requires mkvmerge and mkvextract in PATH, L-SMASH Works (AviSynth plugin).
Extracts audio from container supported by eac3to and trims it according to video trims in script.
Requires eac3to and mkvmerge in PATH, L-SMASH Works if you use lvlibav or FFMS video source.
IVTC script with some post-processing for AviSynth. Intended to use with 2:3:2:3 telecined material. ##Requirements python2 or AvsPmod, avs2yuv, ivtcpp.avsi, Morefun.avsi and shortcuts.avsi from https://github.com/Zeght/Morefun, lots of other AviSynth scripts/plugins such as TIVTC, ApplyEvery, RemapFrames, mvtools, masktools, rgtools, mpeg2stinx2, nnedi3, nnedi3_resize16, QTGMC, Dither tools.
##Implemented features
- IVTC with stable pattern
- automatic ivtc_txt60mc/ivtc_txt30mc when out-of-pattern content is detected on top or bottom part of frame
- auto-applied mpeg2stinx2/nnedi3
- motion compensation for bad-looking decombed frames
- spatial or spatio-temporal deblocking
- optional MDegrain for whole clip
####Setup
- Copy avs2yuv to Path or otherwise make sure it can be called from cmd.
- Copy Morefun and other required plugins to Avisynth autoload folder.
- Copy macron_ivtc_getmetrics.py, macron_ivtc_processmetrics.py (from this git) and Queue.py (from Python2X/Lib/ or Google) to AvsPmod/tools/
- Copy ivtc.py to AvsPmod/macro/
##Basic usage
- Make an .avs script with source filter and open it in AvsPmod, you can trim clip but any other filtering is discouraged.
- Call macro named ivtc.
- Close message after finishing. A new tab with complete .avs ivtc script will be created for your source.
- Save it, add whatever filtering you want.
- Don't put any filters in the middle of generated filterchain unless you actually know what goes in/out and why you need it.
##Advanced usage ###PP Scripts description ####ivtcpp_mixedcontent(clip 60iclip, clip ivtc, string filename, int x1, int y1, int x2, int y2, int inflate, int slow) runs ivtc_txtX0mc on a part of clip using information from file
- 60iclip is initial, non-deinterlaced clip. ivtc is inverse-telecined clip
- filename: path to file with 60i/30p ranges
- x1, y1, x2, y2: coordinates for top-left and bottom-right corners of ivtc_txt60mc/ivtc_txt30mc processing box, can be used to increase performance. Default - process whole clip.
- inflate: amount of box inflation, in pixels. Used to create smooth transition between clip processed by ivtc_txt60mc/ivtc_txt30mc and simple ivtc clip. Default - 40
- slow: parameter for previewing. 0 - disable processing, 1 - draft, >=2 - full processing. Default - 2
- deint: custom deinterlacer to use instead of QTGMC. e.g. "nnedi3(-2)"
####ivtc_pp(clip src, string fileprefix, clip cleanclip, int mc_cleanquality, int mc_colorize, bool fieldcleaning, bool mpeg2, string spdeblock, int mvdeblock_sad, bool demosquito, int slow, bool lsb, bool display) runs nnedi/mpeg2stinx2, deblock, motion compensation and MDegrain using information from files
- src: source clip
- fileprefix: prefix for various files generated by macro
- cleanclip: some clip without artefacts caused by telecine which will be used for motion analysis, usually some low quality web stream. Default - undefined
- mc_cleanquality: shows how bad cleanclip is. Cleanclip will be used as default clip for motion compensation when value in mcompfile is larger than mc_cleanquality. Default - 50
- mc_colorize: changes average colors after motion compensation. 0 - don't change, use motion compensated picture as is. 1 - keep colors when doing unidirectional mocomp, revert when doing bidirectional. 2 - always revert to colors before motion compensation. 3 - change to cleanclip (if provided) colors. Default - 2.
- mpeg2: treat clip as mpeg2 (8x8 TF blocks without in-loop deblocking). Default - true
- spdeblock: function for spatial deblocking. "" (empty string) - disabled, "SD2_file" runs SmoothD2 with strength specified in files which is usually too weak for short-time and some other blocking, "SD2_an" - same but necessary strength is estimated on execution, any other string e.g. "Deblock_QED()" will evaluate corresponding function for deblocking. Default - "SD2_file" for mpeg2, "" for non-mpeg2
- mvdeblock_sad: SAD for MDegrain used for temporal deblocking and degrain/demosquito. Set to zero to disable. Default - 25 (very light)
- demosquito: increase SAD for areas around edges to remove more mosquito noise. Default - true
- fieldcleaning: fieldcleaning with mpeg2stinx2 and nnedi3. May destroy details, but it's better to set higher thresholds in macron_ivtc_processmetrics.py than disable it. Default - true
- slow: enable/disable some of processing. slow=0 - only do nnedi+mpeg2stinx, slow>=1 enables deblock, slow>=2 enables temporal deblocking (if vardeblock is enabled) and motion compensation. slow>2 enables temporal degrain on all frames with (slow-2) temporal radius. Default - 4.
- lsb: 16-bit output. Recommended with slow>2, useless otherwise. Default - true.
- display: show some information about applied filters. Default - false
####ivtcpp_ghostbuster(clip src, float overshoot, bool hint) Some broadcasts have 60i ghosting. First field is usually more ghosted. This script makes second field as bright as first (+ overshoot). Should be called after IVTC. It's important to preserve field order to actually remove ghosting instead of adding more. TFM changes order on p-matches without flagging fields properly so you need to use preserve hints (by disabling hints in TDecimate or applying deghost before TDecimate). "DIY" IVTC (i.e. done with Avisynth internal functions such as Selectevery) flags fields correctly so function will work with those and you can disable "hints" parameter. Telecide (just flips fields with it's own internal functions), JIVTC (calls AssumeTFF() right after IVTC) and maybe some other IVTC plugins won't flag flipped fields. It's better to use ivtcpp_ghostbuster before IVTC if you want deghosting with such plugins.
Parameters:
- overshoot: if =1 makes bright field as dark as second, if > 1 - even darker (multiplies difference by overshoot). Default - 2
- hint: if set to true, uses TFM hints to flip field order on p matches.
####ivtcpp_checkTFMhints(clip src) Checks whether clip contains TFM hints or not
##Tips
- Most of PP values are based on tfm metrics, high values mean bad frames, low values mean good frames.
- Mappings in vardeblock.txt and mc_presets.txt can be sorted by values, you may want too check frames with whe biggest values
- You can edit mappings files manually, m2s2maps.txt and deblock.txt are usual RFS ranges, nnedi.txt specifies which nnedi mode to use (0 or 1), vardeblock.txt and mc_presets.txt specifies strength of post-processing (negative values in mc_presets.txt are standing for unidirectional motion compensation, positive - for bidirectional), mixtop.txt and mixbottom.txt contains ranges and frame_ref parameters for ivtc_txtX0mc, tfmovr.txt and tdcovr.txt are usual TFM/TDecimate override files.
- You can use macron_ivtc_getmetrics.py and macron_ivtc_processmetrics.py in command line. macron_ivtc_getmetrics.py creates metrics from output of avisynth script, macron_ivtc_processmetrics.py uses those metrics to create mappings for TIVTC and ivtcpp.
##Script templates Default template is
slow = 2
display = false
prefix = "%prefix"
%source
#You should fix borders before processing (fixborders/balanceforders/fillmargins)
#Delogo helps a bit too
src = last#.fixborders(l="d2;d1", r="d2;d1")
ivtc = src.tfm(pp=0, ovr=prefix+"tfmovr.txt").tdecimate(ovr=prefix+"tdcovr.txt")
croph = src.Height()/18*4
inflate = 40
ivtc
ivtcpp_mixedcontent(src, last, prefix+"mixbot.txt", y1=src.Height()-croph, inflate=inflate, slow=slow)
ivtcpp_mixedcontent(src, last, prefix+"mixtop.txt", y2=croph, inflate=inflate, slow=slow)
ivtcpp(fileprefix=prefix, slow=slow, display=display, lsb=false)
%prefix is replaced with prefix to path to files which you chose in macro.
%source is replaced with a script you had when you called IVTC macro.
You can use a custom template by saving it as Macron_IVTC_template.avsi in AvsPmod/macros directory. ###Script examples ####H264 clip
slow = 4
display = false
prefix = "atx_"
filepath = "atx.ts"
lwlibavvideosource(filepath)
src = last
ivtc = src.tfm(pp=0, ovr=prefix+"tfmovr.txt", hints=false).tdecimate(ovr=prefix+"tdcovr.txt", hints=false)
croph = src.Height()/18*4
inflate = 40
ivtc
ivtcpp_mixedcontent(src, last, prefix+"mixbot.txt", y1=src.Height()-croph, inflate=inflate, slow=slow)
ivtcpp_mixedcontent(src, last, prefix+"mixtop.txt", y2=croph, inflate=inflate, slow=slow)
ivtcpp(fileprefix=prefix, slow=4, display=display, lsb=true, mpeg2=false)
####Deghost and PP with fairly strong mdegrain
slow = 4
display = true
prefix = "tva_"
filepath = "tva.ts"
lwlibavvideosource(filepath)
src = last
ivtc = src.tfm(pp=0, ovr=prefix+"tfmovr.txt").tdecimate(ovr=prefix+"tdcovr.txt", hints=false)
croph = src.Height()/18*4
inflate = 40
ivtc
ivtcpp_mixedcontent(src, last, prefix+"mixbot.txt", y1=src.Height()-croph, inflate=inflate, slow=slow)
ivtcpp_mixedcontent(src, last, prefix+"mixtop.txt", y2=croph, inflate=inflate, slow=slow)
ivtcpp_ghostbuster()
ivtcpp(fileprefix=prefix, slow=slow, display=display, lsb=true, mvdeblock_sad=40)
####repair borders, extra strong demosquito/MDegrain and no fieldcleaning on one segment of clip
slow = 4
display = false
prefix = "mosquito_"
filepath = "mosquito.ts"
lwlibavvideosource(filepath)
src = last.fixborders(l="222:221 222 220 225 214 233 184d1; 154:155 156 148 138", r="222:221 225 219 227 214 232 200 116.5; d1", border=12)
ivtc = src.tfm(pp=0, ovr=prefix+"tfmovr.txt", hints=false).tdecimate(ovr=prefix+"tdcovr.txt", hints=false)
croph = src.Height()/18*4
inflate = 40
ivtc
ivtcpp_mixedcontent(src, last, prefix+"mixbot.txt", y1=src.Height()-croph, inflate=inflate, slow=slow)
ivtcpp_mixedcontent(src, last, prefix+"mixtop.txt", y2=croph, inflate=inflate, slow=slow)
regular = ivtcpp(fileprefix=prefix, slow=4, display=display, lsb=true)
demosquito = ivtcpp(fileprefix=prefix, slow=5, fieldcleaning=false, display=display, lsb=true, mvdeblock_sad=100)
regular.ReplaceFramesSimple(demosquito , mappings="[994 3915]")