Skip to content

VapourSynth, Unsharp Filter & VMAF Updates

Compare
Choose a tag to compare
@patrickenfuego patrickenfuego released this 29 Jul 02:49
· 60 commits to main since this release
0b7d373

What's New

This release comes with a few new exciting features, several updates to existing features, and quite a few bug fixes as well, some of which were unintentionally added in the last release.

New Features

Vapoursynth Integration

I'm a big fan of Vapoursynth, so this is something I've wanted to implement for a while now. It was frustrating to have two separate workflows, one for ffmpeg and one for VapourSynth, so I went about adding it to the script.

ffmpeg can be compiled with native VapourSynth demuxing support through the --enable-vapoursynth compilation flag, and this is a requirement for this feature to work on all non Dolby Vision sources (more on that in a second). This allows you to feed a VapourSynth script directly to ffmpeg without using VSPipe, thus reducing overhead and complexity.

However, because Dolby Vision encoding still uses x265, I had to implement a VSPipe workaround as ffmpeg still isn't handling RPU files properly as of version 5. To summarize:

  • All non Dolby Vision encodes will use the native VapourSynth demuxer compiled with ffmpeg
  • Dolby Vision encodes will use VSPipe instead, which must be available via PATH. The VapourSynth script is then piped directly to x265

Some Notes on Usage

  • The -InputPath parameter is still required, even when using a VapourSynth script; it is used to discover properties used throughout the script, and is also used to encode/copy audio and subtitles (if selected)
    • The source must be present in the VapourSynth script, too, as it handles the filtering
  • Video filter-related parameters will be ignored when a VapourSynth script is used - all filtering must be done in the VapourSynth script, including cropping

See the wiki for usage details.

Sharpen / Blur Filter

I've added two new parameters for applying sharpening and blur filters to the video using unsharp. The new parameters are -Unsharp and -UnsharpStrength, and each parameter comes with several presets I've created to make things easier. Each parameter includes tab-complete support, too, so you can tab through and see your options.

For -Unsharp, the preset options sets the type of filtering (luma, chroma, yuv) with a postfix denoting the search area (small, medium, large). You also have the option to pass a custom filter string if you don't want to use a preset, and the string will be passed to ffmpeg - the only string manipulation done is replacing custom= with unsharp= if it isn't already present.

For -UnsharpStrength, the prefix denotes whether the filter should sharpen or blur, while the postfix controls the strength. If a custom filter string is passed via -Unsharp, this parameter is ignored.

Options for -Unsharp

  • luma_small
  • luma_medium
  • luma_large
  • chroma_small
  • chroma_medium
  • chroma_large
  • yuv_small
  • yuv_medium
  • yuv_large
  • custom=<custom_filter_string>

Options for -UnsharpStrength

  • sharpen_mild
  • sharpen_medium
  • sharpen_strong
  • blur_mild
  • blur_medium
  • blur_strong

Updates

This release comes with updates to several existing features.

Background Audio Jobs Update

Previously, if a background audio job didn't complete before the video did, the script would continue on and prompt you to add the audio manually. I realized this was kind of stupid, so the script will now wait for the background job to complete before proceeding.

VMAF Updates

By default, libvmaf v.2.0.0+ only uses one thread, which can be horribly slow depending on the comparison. I've updated the code to query the number of logical processors on the system (using native commands for each supported Operating System) and use ~ 50% of the resources during comparisons, which speeds things up a lot.

FPS Counter in Progress Bar

You can now see your current FPS directly in the progress bar. Sweet.

Other Updates

  • A few subtitle and audio options have new banner wording to clear up some confusing verbiage
  • More code optimizations to improve performance using native .NET calls wherever possible

Bug Fixes

A number of bugs have been fixed in this release:

  • Fixed resource lockout on the encoding log when running multiple encodes of the same source simultaneously. The script will now check if there is an existing encode locking the log file, and create a new log if necessary
  • Fixed track name field duplication in mkvmerge. Somehow the same line of code was repeated 3 times, causing issues while naming audio tracks
  • VMAF bug fixes
    • Removed extra whitespace in the resolution check function, which was added by my autoformatter and caused ffmpeg to freak out
    • Fixed regex match failure while checking resolution. This is definitely a bug with PowerShell's $Matches variable and not the script, and the functionality has been replaced with a .NET method call
    • Fixed model and log file path logic on Windows
  • Fixed hard-coded, non-overriding values for keyint / min-keyint when performing a Dolby Vision encode