Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > VapourSynth

Reply
 
Thread Tools Search this Thread Display Modes
Old 19th September 2023, 11:07   #1  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,787
SAR in frame properties vs. resizer cropping

VapourSynth appears not to factor-in resizer cropping when calculating a SAR for frame properties.

The starting point is a non-anamorphic 1280x720 source.

clip = core.std.Crop(clip, 20,0,0,0)
clip = core.resize.Spline36(clip, 720,576)
The SAR in frame properties changes from 1:1 to 7:5. So far so good.

clip = core.resize.Spline36(clip, 720,576, src_left=20, src_top=0, src_width=1260, src_height=720)
The SAR in frame properties changes from 1:1 to 64:45.

clip = core.resize.Spline36(clip, 720,576, src_left=20, src_top=0, src_width=20, src_height=760)
Still 64:45.

Cheers.

Last edited by hello_hello; 19th September 2023 at 11:14.
hello_hello is offline   Reply With Quote
Old 20th September 2023, 16:04   #2  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,530
Will fix
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 21st September 2023, 11:24   #3  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,787
Thanks. A question though....

Is the SAR in frame properties generally used automatically for encoding, or is it something that still must be specified in the command-line, and if they're different, which would be used?
An example (I haven't actually encoded much video using VapourSynth yet) would be DVD resizing that can have an ITU/MPEG4 or Generic SAR, depending on which aspect ratio the user thinks is correct, and based on that, the resulting SAR in frame properties mightn't be the desired one.

I'm asking as I've just about completed a Vapoursyth version of this function (it's SAR calculations are how I discovered the problem) so I'm wondering if I should be ensuring the SAR in frame properties is always the expected one.

I'm hoping the answer is "no" but I'm fairly sure that's just wishful thinking.

Cheers.
hello_hello is offline   Reply With Quote
Old 21st September 2023, 13:34   #4  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,530
Quote:
Originally Posted by hello_hello View Post
Is the SAR in frame properties generally used automatically for encoding, or is it something that still must be specified in the command-line, and if they're different, which would be used?
FFmpeg's vapoursynth source reads the frame properties properly. If it's passed with y4m headers you need to specify the aspect ratio manually. Not sure if anything else directly reads the frame properties.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 24th September 2023, 20:14   #5  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,530
Please test the SAR fix in R64-RC2
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 25th September 2023, 17:28   #6  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,157
btw. any hope for an option to disable autoloading filters through some parameter/function in Vapoursynth?
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 26th September 2023, 07:46   #7  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,787
Quote:
Originally Posted by Myrsloik View Post
Please test the SAR fix in R64-RC2
Thanks. I'll probably have to wait for the update to find it's way to the deb-multimedia repo to test in on Linux, but I'll try to install it on Windows in VirtualBox soon to test it that way. It might be a little while before I get to it though.

Cheers.
hello_hello is offline   Reply With Quote
Old 26th September 2023, 14:24   #8  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,787
Edit: I remembered there's a mod version of VapourSynth Edit, so I thought I'd give it a try.
https://github.com/YomikoR/VapourSynth-Editor
It's working normally so I'll do some testing soon, once I've worked out where to put functions so they can be imported easily.


I gave it a shot, but VapourSynth won. It's only torturing me.
I tried R64-RC2 and R63 with both the portable and an installed version of Python. Any idea why this is happening? The script evaluates okay but VS Edit opens the preview without any video.
I tried putting the video file in a different place (other than the root of the C drive) thinking that might be the cause, but it didn't make any difference.
It's Windows 11 in VirtualBox but I can't image why that'd matter.

I'm not sure where the version of ffms2 I had came from. I'm pretty sure it was downloaded from VSRepo a while back, and while I reverted the Win11 VirtualBox install to an older one soon after, I kept all the downloaded plugins. Just to be sure though, I replaced ffms2.dll with this version, but nothing changed. https://github.com/FFMS/ffms2



By the way, I was reading the instructions for using BestSource on the VapourSynth website but I couldn't find anywhere to download it. Is it still a thing?

Last edited by hello_hello; 27th September 2023 at 08:40.
hello_hello is offline   Reply With Quote
Old 27th September 2023, 09:42   #9  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,157
Does "C:\\0201.mkv", instead of "C:\\0201.mkv" try "C:/0201.mkv" or r"C:\0201.mkv"

Cu Selur
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 27th September 2023, 11:12   #10  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,787
Quote:
Originally Posted by Selur View Post
Does "C:\\0201.mkv", instead of "C:\\0201.mkv" try "C:/0201.mkv" or r"C:\0201.mkv"

Cu Selur
It shouldn't be, especially as the result of F6 (evaluating the script) shows it's okay. Plus if I run the script before an index file exists, it's created normally.

I did check though, and using r"C:\0201.mkv" doesn't change anything.
You may not have seen the edit of my previous post, but I discovered the mod version of VSEdit is working fine, so I'm currently using that for testing.

It's led me to discover a typo in the VapourSynth CropResize that was resulting in some SAR madness. I've fixed that, but there's still a SAR oddity in frame properties that happens now and then, so at the moment I'm trying to work out whether it's CropResize or VapourSynth doing a silly.
hello_hello is offline   Reply With Quote
Old 27th September 2023, 15:06   #11  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,787
It looks like there's a math problem. I'm testing "VapourSynth-x64-R64-RC2.exe". The source is 1280x720.

The reason for the tiny amount of height cropping below is because it's what's required for a SAR of 64:45 (1.422222) when 1 pixel is also cropped from the left.

Code:
ClipW = clip.width
ClipH = clip.height

PropsNumIn = clip.get_frame(0).props.get('_SARNum', 0)
PropsDenIn = clip.get_frame(0).props.get('_SARDen', 0)

clip = core.resize.Spline36(clip, 720,576, src_left=1, src_top=0.281, src_width=1279, src_height=719.438)

PropsNumOut = clip.get_frame(0).props.get('_SARNum', 0)
PropsDenOut = clip.get_frame(0).props.get('_SARDen', 0)

clip = core.text.Text(clip, f' Source {ClipW}x{ClipH}   ' + \
f'PropsIn {PropsNumIn}:{PropsDenIn}   ' + \
f'PropsOut  {PropsNumOut / PropsDenOut} ({PropsNumOut}:{PropsDenOut})', alignment=2)


PS Is there a better place to put user functions on Windows than in the "Program Files/Python311/Lib" folder?
They'll import from there with something like
import MyFunction as MF
but I'd prefer to keep user functions separate in their own folder.

And the BestSource source filter mentioned on the VapourSynth website... I couldn't find anywhere to download it. Is it still a thing?

Last edited by hello_hello; 27th September 2023 at 15:23.
hello_hello is offline   Reply With Quote
Old 27th September 2023, 16:12   #12  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,157
Maybe this helps: I keep all my scripts in: 'F:/Hybrid/64bit/vsscripts' and import them through
Code:
# Import scripts folder
scriptPath = 'F:/Hybrid/64bit/vsscripts'
sys.path.insert(0, os.path.abspath(scriptPath))
note: this requires 'import sys' and 'import os'

Cu Selur
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 27th September 2023, 17:37   #13  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,530
Quote:
Originally Posted by hello_hello View Post
It looks like there's a math problem. I'm testing "VapourSynth-x64-R64-RC2.exe". The source is 1280x720.

The reason for the tiny amount of height cropping below is because it's what's required for a SAR of 64:45 (1.422222) when 1 pixel is also cropped from the left.

Code:
ClipW = clip.width
ClipH = clip.height

PropsNumIn = clip.get_frame(0).props.get('_SARNum', 0)
PropsDenIn = clip.get_frame(0).props.get('_SARDen', 0)

clip = core.resize.Spline36(clip, 720,576, src_left=1, src_top=0.281, src_width=1279, src_height=719.438)

PropsNumOut = clip.get_frame(0).props.get('_SARNum', 0)
PropsDenOut = clip.get_frame(0).props.get('_SARDen', 0)

clip = core.text.Text(clip, f' Source {ClipW}x{ClipH}   ' + \
f'PropsIn {PropsNumIn}:{PropsDenIn}   ' + \
f'PropsOut  {PropsNumOut / PropsDenOut} ({PropsNumOut}:{PropsDenOut})', alignment=2)


PS Is there a better place to put user functions on Windows than in the "Program Files/Python311/Lib" folder?
They'll import from there with something like
import MyFunction as MF
but I'd prefer to keep user functions separate in their own folder.

And the BestSource source filter mentioned on the VapourSynth website... I couldn't find anywhere to download it. Is it still a thing?
Doh, I flipped source an destination height when cropping. Maybe the next version will please you...
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:46.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.