Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should high quality alignment be the default when aspect ratios of sources match? #85

Closed
jimalad opened this issue Nov 28, 2024 · 1 comment

Comments

@jimalad
Copy link

jimalad commented Nov 28, 2024

Thank you for developing this tool.

I'm using 20241124 on Windows, trying it with 1080p to 720p downscale re-encodes (i.e. evaluating downscaling algorithm choice, codecs and compression settings etc.).
With default command line usage, I noticed what I thought was a subtle colour error and a 1-pixel or sub-pixel lateral shift on the re-encoded (right hand) side, but couldn't initially pin it down as the issue only jumped out with certain video content.
Adding "-r scale=1920:1080:flags={algorithm}" fixed it (presumably because video-compare no longer tries any alignment strategies when sources have exactly matching resolutions?), but I later realised "--hq-alignment" also fixed it.
I initially thought it might be tied-up somehow in the new 'T' key feature (should this have a command line option BTW?), but I now don't think that's related.
I wonder could the tool be improved to correctly align sources with the same aspect ratio (i.e. a common use-case) by default.

Here's minimal steps to reproduce...

# save ground.jpg (512px x 512px) from the page below as ground.jpg
# (I found the image via google image search, constraining to github.com)
# https://github.com/BabylonJS/Documentation/blob/master/content/toolsAndResources/assetLibraries/availableTextures.md
# SHA256: e3637cbd17d1f086f32ebdf21c8399b0bac9d6dccecae1bd2207482895e17678

# create a downscaled version of the reference image (512px x 512px > 384px x 384px)
ffmpeg -hide_banner -i ground.jpg -vf scale=384:384:flags=lanczos -frames:v 1 -update 1 ground_384.png

# test video-compare with default commandline usage.
# zoom in with '8' key and rapidly move the comparison wiper left to right to see the blurry sub-pixel shift more clearly.
video-compare ground.jpg ground_384.png

# fixed with "--hq-alignment"
video-compare --hq-alignment ground.jpg ground_384.png

# alternatively fixed by pre-upscaling the downscaled image
video-compare -r scale=512:512:flags=lanczos ground.jpg ground_384.png
@jonfryd
Copy link
Member

jonfryd commented Nov 28, 2024

Hi @jimalad,

I'm glad to hear you find the tool useful, and thank you for providing a detailed description of how to reproduce the issue.

I agree that, for your use case, the aliasing caused by bilinear scaling - resulting from only computing a weighted average of the 4 neighboring pixels - is very noticeable compared to bicubic interpolation, which utilizes 16 samples.

Perhaps we should drop --hq-alignment and replace it with --fast-alignment, which would prioritize speed instead. I'll give it some thought.

jonfryd added a commit that referenced this issue Nov 28, 2024
…liasing issues, while retaining bilinear scaling as the default when the resolution is identical on both sides for performance reasons
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants