Optimizing Video Quality with AviSynth+: Tips & TricksAviSynth+ is a powerful, script-driven frameserver that gives advanced users fine-grained control over video processing. Built as an enhanced fork of the classic AviSynth, AviSynth+ adds multithreading, performance improvements, wider filter support, and modern conveniences while remaining script-centric. This article covers practical tips and techniques you can apply to maximize video quality while keeping processing efficient and reproducible.
Understanding the Workflow
Before applying filters, understand the typical processing pipeline:
- Source acquisition — capture or demux your footage (AVI, MP4, MKV, raw frames).
- Color space conversion — ensure correct color format for editing/filters (RGB, YV12, YUV420p, YUV444).
- Denoising — remove sensor/grain noise without destroying detail.
- Deblocking/deringing — fix compression artifacts (blockiness, ringing).
- Debanding — remove banding introduced by compression or color grading.
- Sharpening/upscaling — improve perceived detail cautiously.
- Color correction/grading — adjust levels, contrast, saturation.
- Resizing and output encoding — final size and codec decisions.
Work from lossless or highest-quality sources whenever possible and keep an uncompressed or minimally compressed intermediate if you plan multiple passes.
Choose the Right Color Space and Bit Depth
- Always operate in an appropriate color space and bit depth for the filters you’ll use. Many denoising and scaling filters work better in higher bit depths. AviSynth+ supports 16-bit integer and 32-bit float via plugins and conversions.
- Convert to a high-bit-depth YUV or RGB before heavy processing, e.g. using ConvertToYUV or ConvertToRGB32, then ConvertToYV24/ConvertToRGB64 if needed.
- For filming with high dynamic range or heavy grading, process in full-range RGB or float where possible to reduce quantization artifacts.
Denoising: Preserve Detail, Remove Noise
Denoising is one of the highest-impact steps for perceived quality. Over-aggressive denoising creates plastic, smeared results; under-denoising leaves distracting noise.
Recommended denoisers:
- DFTTest/FFT3DFilter — frequency-domain denoising, good for static noise patterns.
- MCTemporalDenoise (MCT) — motion-compensated temporal denoiser that preserves detail across frames.
- BM3D/BlockMatching filters — sophisticated denoisers with excellent detail preservation (via external plugins/wrappers).
- KnlMeansCL — GPU-accelerated Non-Local Means (fast and high quality).
Tips:
- Always denoise before resizing and sharpening.
- Use motion-compensated denoisers for footage with camera/object motion to avoid ghosting.
- Apply stronger denoising on chroma than on luma if color noise is prevalent (e.g. separate planes).
Example pattern:
# Example: Convert and temporal denoise (pseudocode) source = FFmpegSource2("input.mkv") highbit = ConvertToRGB32(source) # float/int pipeline as needed denoised = MCTemporalDenoise(highbit, ...parameters...)
Deblocking and Deringing
Compressed video (especially low-bitrate) often suffers from blockiness and ringing around edges.
- Use filters like Deblock (BWDif variants), Deband, and Deringing-specific tools to address these.
- FFT-based filters can reduce subtle ringing while preserving crisp edges.
- Apply deblocking before sharpening; deringing can be done after denoise but before final sharpening.
Example:
clean = FFT3DFilter(denoised, ...) deringed = Deringmod(clean, ...)
Debanding: Smooth Gradients Without Losing Detail
Banding is visible as stepped gradients. Debanding smooths these while trying not to blur textures.
- Use Deband (GradFun3, placebo Deband, f3kdb) with small radius and threshold tuned to footage.
- Add subtle dithering (grain) after debanding to mask remaining bands while restoring natural texture.
- Preserve fine detail by masking debanding to flat areas using edge detectors (e.g., Prewitt, Sobel) or Luma-based masks.
Example:
debanded = f3kdb(deringed, range=15, y=64, cb=64, cr=64) grain = AddGrainC(debanded, 0.05, 0.02)
Resizing and Upscaling
When changing resolution:
- Use high-quality resizers: Spline36, Lanczos, nnedi3 for upscaling, or EEDI3+NNEDI3 for best detail reconstruction.
- For significant upscales (e.g., SD→HD), consider multi-stage upscaling: a detail-preserving scalers first (EEDI3/nnedi3) then refinement with a spline or Lanczos pass.
- Convert to a high bit-depth before resizing to avoid color banding and rounding artifacts.
Example upscaling:
resized = nnedi3_rpow2(deringed, rfactor=2) resized = Spline36Resize(resized, 1920, 1080)
Sharpening: Subtlety Is Key
Sharpening increases perceived detail but amplifies noise and artifacts.
- Use MSharpen, UnsharpMask, or LimitedSharpenFaster with a mask so sharpening affects edges more than flat areas.
- Prefer directional or edge-aware sharpeners to avoid boosting noise.
- Apply sharpening after denoising/resizing but before final encoding. If final codec is aggressive, reduce sharpening strength to avoid halo artifacts.
Example:
edge_mask = Sobel(denoised).Binarize(10) sharpened = LimitedSharpenFaster(resized, 2.0, 0.5) final_sharp = Mask(sharpened, edge_mask)
Color Correction and Grading
- Do primary corrections first (levels, contrast, white balance), then secondary corrections (selective color, skin tones).
- Use histogram and vectorscope tools to monitor clipping and color balance.
- Work in a wide color/bit-depth space for grading, then convert to target output color space before encoding.
Useful filters:
- Levels, Tweak, ColorYUV, GradFun3, Histogram adjustments.
- For precise grading, consider exporting to a color grading application then re-importing uncompressed frames for AviSynth finishing.
Encoding: Preserve Quality
- Render to a minimally lossy intermediate (e.g., ProRes, DNxHD, lossless H.264 options, or raw frames) if multiple edits/passes are expected.
- For final delivery, choose a codec and bitrate appropriate for the content and distribution channel (HEVC for efficient high-quality, H.264 for compatibility).
- Use two-pass or CRF-based encoders (x264/x265) and tune presets to balance quality and file size.
- Consider using high-quality deblocking and psy tuning in the encoder, remembering that heavy pre-processing (sharpening/debanding) interacts with encoder filters.
Example FFmpeg encode command (reference only):
ffmpeg -i processed.mkv -c:v libx265 -preset slow -crf 18 -x265-params "psy-rd=2.0:aq-mode=3" output.mp4
Automation and Reproducibility
- Keep scripts modular and well-commented so you can reuse parts for different clips.
- Use AviSynth+’s multithreading and optimizations but test filters single-threaded if debugging artifacts.
- Store presets for denoising, debanding, and sharpening tailored to your camera/codec combinations.
Common Pitfalls and How to Avoid Them
- Over-denoising → loss of detail: use motion compensation and conservative settings.
- Over-sharpening → halos and amplified noise: use masks and limit sharpening strength.
- Wrong color space conversions → washed colors or clipping: always track your color pipeline.
- Applying filters in the wrong order → inefficient or broken results: denoise → deblock/dering → deband → resize → sharpen → grade → encode.
Example End-to-End AviSynth+ Script (Simplified)
# Simplified processing pipeline (adjust parameters per source) source = FFmpegSource2("input.mkv") high = ConvertToRGB32(source) # Temporal denoise (example; plugin-specific) den = MCTemporalDenoise(high, tr=2, thsad=200) # Spatial clean-up clean = FFT3DFilter(den, sigma=2, plane=4) # Dering and deband der = Deringmod(clean, 10, 3) deband = f3kdb(der, y=64, cb=64, cr=64, grain=0) # Resize and sharpen resized = Spline36Resize(deband, 1920, 1080) sharpen = LimitedSharpenFaster(resized, 1.5, 0.7) # Final color tweak and convert to YUV for encoder final = Tweak(sharpen, bright=1, cont=1.05) finalyuv = ConvertToYV12(final) return finalyuv
Closing Notes
Optimizing video quality in AviSynth+ is a balance between removing unwanted artifacts and preserving or enhancing true detail. Rely on targeted filters, work in appropriate color/bit-depth spaces, and test carefully with masks and conservative settings. Scripts let you reproduce results precisely and iterate quickly — build a library of presets for your most common sources to save time and keep output consistent.
Leave a Reply