master-of-zen / Av1an

Cross-platform command-line AV1 / VP9 / HEVC / H264 encoding framework with per scene quality encoding
GNU General Public License v3.0
1.4k stars 147 forks source link

Possible issue with video scaling and VMAF targeting/calculation #830

Open ioctl-user opened 1 month ago

ioctl-user commented 1 month ago

Looks like VMAF targeting process is not corresponds with the final VMAF when using the scaling filter.

Steps to reproduce including input file generation:

ffmpeg -f lavfi -i mandelbrot=end_pts=50:size=3840x2160 -vf scale=out_range=pc -pix_fmt yuv420p10le -t 9 mandelbrot-4k.mkv

av1an -i mandelbrot-4k.mkv -m lsmash --extra-split-sec 2 -e  svt-av1 -v "--preset 5" -f " -vf scale=1920:-1:flags=lanczos:out_range=pc " --vmaf-filter "scale=1920:-1:flags=lanczos:out_range=pc" --target-quality 90 -l log-mandelbrot-q90 -o mandelbrot-out.mkv

So, requested target VMAF was above 90, output VMAF is 100 for each frame according to the SVG-file mandelbrot-out

At that, the log file contains dramatically worse VMAF numbers:

DEBUG [av1an_core::context] temporary directory: .f68a260
INFO [av1an_core::context] Input: 3840x2160 @ 25.000 fps, YUV420P10LE, SDR
INFO [av1an_core::context] scenecut: found 1 scene(s) [with extra_splits (50 frames): 5 scene(s)]
DEBUG [av1an_core::target_quality] chunk 00000: P-Rate=1, 45 frames
DEBUG [av1an_core::target_quality] chunk 00000: TQ-Probes: [(66.34, 15), (66.04, 32)] Early Skip Low Q
DEBUG [av1an_core::target_quality] chunk 00000: Target Q=15, VMAF=66.34
DEBUG [av1an_core::broker]  started chunk 00000: 45 frames
DEBUG [av1an_core::broker] finished chunk 00000: 45 frames, 1.24 fps, took 36.19s
DEBUG [av1an_core::target_quality] chunk 00001: P-Rate=1, 45 frames
DEBUG [av1an_core::target_quality] chunk 00001: TQ-Probes: [(65.79, 15), (65.55, 32)] Early Skip Low Q
DEBUG [av1an_core::target_quality] chunk 00001: Target Q=15, VMAF=65.79
DEBUG [av1an_core::broker]  started chunk 00001: 45 frames
DEBUG [av1an_core::broker] finished chunk 00001: 45 frames, 1.40 fps, took 32.25s
DEBUG [av1an_core::target_quality] chunk 00002: P-Rate=1, 45 frames
DEBUG [av1an_core::target_quality] chunk 00002: TQ-Probes: [(63.87, 15), (63.58, 32)] Early Skip Low Q
DEBUG [av1an_core::target_quality] chunk 00002: Target Q=15, VMAF=63.87
DEBUG [av1an_core::broker]  started chunk 00002: 45 frames
DEBUG [av1an_core::broker] finished chunk 00002: 45 frames, 1.09 fps, took 41.41s
DEBUG [av1an_core::target_quality] chunk 00003: P-Rate=1, 45 frames
DEBUG [av1an_core::target_quality] chunk 00003: TQ-Probes: [(62.07, 15), (61.78, 32)] Early Skip Low Q
DEBUG [av1an_core::target_quality] chunk 00003: Target Q=15, VMAF=62.07
DEBUG [av1an_core::broker]  started chunk 00003: 45 frames
DEBUG [av1an_core::broker] finished chunk 00003: 45 frames, 0.95 fps, took 47.39s
DEBUG [av1an_core::target_quality] chunk 00004: P-Rate=1, 45 frames
DEBUG [av1an_core::target_quality] chunk 00004: TQ-Probes: [(61.74, 15), (61.34, 32)] Early Skip Low Q
DEBUG [av1an_core::target_quality] chunk 00004: Target Q=15, VMAF=61.74
DEBUG [av1an_core::broker]  started chunk 00004: 45 frames
DEBUG [av1an_core::broker] finished chunk 00004: 45 frames, 0.76 fps, took 58.88s
DEBUG [av1an_core::context] encoding finished, concatenating with ffmpeg
DEBUG [av1an_core::concat] FFmpeg concat command: "ffmpeg" "-y" "-hide_banner" "-loglevel" "error" "-f" "concat" "-safe" "0" "-i" "/tmp/.f68a260/concat" "-map" "0" "-c" "copy" "/tmp/mandelbrot-out.mkv"