Alkl58 / NotEnoughAV1Encodes

GUI for AV1 (aomenc, rav1e & svt-av1)
MIT License
541 stars 24 forks source link

[Feature] Resizing #84

Closed Ichisich closed 2 years ago

Ichisich commented 2 years ago

Currently, NEAV1E only supports one scaling algorithm. (Bicubic?) It would be nice to offer some of which ffmpeg already supports: https://ffmpeg.org/ffmpeg-scaler.html#Scaler-Options

Especially, Spline, Lanczos, Linear and Nearest_Neighbour would be nice to have. If possible the inclusion of Mitchell would be much appreciated, imo the best downscale algorithm.

neoOpus commented 2 years ago

Better if it can use madshi video renderer advanced resizing algorithms

Alkl58 commented 2 years ago

If possible the inclusion of Mitchell would be much appreciated

Is this a filter which is usable by the ffmpeg scaler flag? I can only find a reference for the v360 filter used to convert 360° videos. https://ffmpeg.org/ffmpeg-filters.html#v360

Better if it can use madshi video renderer advanced resizing algorithms

Same question to this as above, can't find a reference of this in ffmpeg,

neoOpus commented 2 years ago

http://madvr.com/

Alkl58 commented 2 years ago

http://madvr.com/

Please give me an example command to use madvr in ffmpeg.

neoOpus commented 2 years ago

Sorry did some research and I don't think it is possible

Ichisich commented 2 years ago

Is this a filter which is usable by the ffmpeg scaler flag?

In theory.

Mitchell: -sws_flags bicubic -param0 1/3 -param1 1/3

Catmull-rom: -sws_flags bicubic -param0 0 -param1 1/2

I tested it and ffmpeg seems to be very inconsistent. Mitchell gives the expected result, but Catmull-rom is identical to the former, although it should be sharper in appearance. I'm not sure ffmpeg really considers the exact B,C parameter and instead just defaults to specific presets.

neoOpus commented 2 years ago

Found these projects for inspiration

https://github.com/k4yt3x/video2x https://github.com/nihui/waifu2x-ncnn-vulkan https://github.com/fnx4/ffmpeg-multi-waifu https://github.com/akai-katto/dandere2x

Alkl58 commented 2 years ago

@neoOpus: Implementing some sort of AI / SRCNN upscaler, which heavily relies on GPUs won't be happening in NEAV1E. It would drastically reduce encoding speed. People who really want to use waifu2x, esrgan or madvr should upscale beforehand and then encode in neav1e.

@Ichisich I have been searching for the last few hours about mitchell and other scaling filters regarding param0 and param1. Apparently the Bicubic scaler is by default Catmull-Rom in ffmpeg: github.com/HandBrake/HandBrake/issues/1515 Regarding Mitchell I can only find this open enhancement ticket on the ffmpeg bug tracker: https://trac.ffmpeg.org/ticket/7957

Finding actual data about this topic is quite hard - and as I am not sure and can't find anything useful, I probably won't add param0 and param1. Sorry for that, maybe in the future.

Ichisich commented 2 years ago

Yes, it seems ffmpeg's bicubic uses b=0 and c=0.6 as default, which result in a slightly sharper looking albeit numerical inaccurate (b+2c≠1) catmull-rom. Mitchell uses b=1/3 and c=1/3 which is the recommended setting according to the researchers and looks like a more accurate (cubic) version of bilinear without perceivable artefacts. https://en.wikipedia.org/wiki/Mitchell%E2%80%93Netravali_filters#Subjective_effects

I know mpv, which is build heavily upon ffmpeg, uses Mitchell in its high-quality-preset as a downscaler (spline36 for upscaling) and as its temporal scaler. https://mpv.io/manual/stable/#options-mitchell

But as I already wrote, in my testing, param0 and param1 acted highly suspicious. I would also stick to ffmpeg's default scaler presets. Most common and useful are: bilinear bicubic (default) neighbor lanczos spline

Alkl58 commented 2 years ago

Added Filters in Release: https://github.com/Alkl58/NotEnoughAV1Encodes/releases/tag/v2.0.5

Will stick to the standard ffmpeg resizing algorithms for the foreseeable future.

Many Greetings