k4yt3x / video2x

A machine learning-based lossless video super resolution framework. Est. Hack the Valley II, 2018.
https://video2x.org
GNU Affero General Public License v3.0
10.88k stars 1.02k forks source link

SAR and DAR Aspect Ratios Problem #161

Closed Criuion closed 1 month ago

Criuion commented 5 years ago

Hi,

Version: Current and all previous versions.

Issue: Aspect ratios on some videos get broken when upscaled because it uses the wrong Aspect Ratio. SAR instead of DAR.

If you don't know what SAR and DAR are, i wouldn't blame you. SAR is used for old 4:3 Monitors, DAR is used for current 16:9 monitors, so that the video is displayed correctly and not stretched or squashed.

Example: A old anime that says it is 720x480, but will play it back at 853x480 so it looks correct. You can see this in Media Player Classic when playing some old anime if you go to File>Properties and the Details tab you can see it's current resolution being played at.
Can also right click on video playback Video Frame>Aspect Ratio and change between Default (DAR) and Assume Square Pixels (SAR) to see the difference.

Only work around at the minute is to open one anime video at a time in a video editor and export it with the DAR resolution and then upscale it using Video2x.

If you can make a fix for this, it would be awesome. Would make upscaling some of my favourite shows alot faster and less tedious.

k4yt3x commented 5 years ago

Thanks for the in-depth explanation about the problem. I appreciate the time you took to write this clear description.

I read briefly about SAR and DAR, but much more work needs to be done to actually fix the problem in v2x. I would need a few things:

  1. Completely understand SAR and DAR
  2. Understand how to implement a fix with Python and FFmpeg
  3. Have a few test sample to ensure the problem is fixed

Do you happen to have any sample videos I can use to test the patches?

owenthewizard commented 5 years ago

What options to ffmpeg would be needed to "export with the DAR resolution"?

k4yt3x commented 4 years ago

Note: these args can be used in FFmpeg to change PAR, SAR and DAR.

Orion4000 commented 4 years ago

I'm very sorry to jump in on the thread but I wanted to ask a question related to SAR. So I'm using the latest release 4.6.0 and it's working great but my problem is that my video is 16:9 and after finishing the upscale the result is 4:3 and I don't know how to make it so that the video will stay as 16:9 after the upscale.

k4yt3x commented 4 years ago

@Orion4000 I don't know either. I have done some research into this but I haven't understood it thoroughly yet. If possible, could you please provide the source video so I can do some tests?

Orion4000 commented 4 years ago

@k4yt3x I sure can provide the source video for you. Alice in Wonderland (1983) - Episode 49- The Non-Birthday.zip

Orion4000 commented 4 years ago

@k4yt3x I used waifu2x ncnn Vulkan settings just so you know as I like it's quality. Thank you very much for your hard work.

Orion4000 commented 4 years ago

@k4yt3x I found something maybe can help you in your test. If I set the resolution of the clip I want to upscale to (1280 x 720) and uncheck "keep aspect ration" it will keep the 16:9 DAR and wont change it to 4:3 but anything below 720p or above it the result will be in 4:3 instead of 16:9.

k4yt3x commented 4 years ago

"Keep Aspect Ratio" is in the frame preview settings, which only applies to the frame preview in the GUI. It has nothing to do with the final output file. I think the solution you found is somewhat faulty or unstable. SAR and DAR should be defined with some FFmepg arguments.

Orion4000 commented 4 years ago

You know more on this than I do. Until you find a more stable permanent solution in the future this solution is all I got to keep 16:9 from changing to 4:3. Thank you for your hard work.