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. |
![]() |
#1 | Link |
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. |
![]() |
![]() |
![]() |
#2 | Link |
Professional Code Monkey
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,530
|
Will fix
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet |
![]() |
![]() |
![]() |
#3 | Link |
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. |
![]() |
![]() |
![]() |
#4 | Link |
Professional Code Monkey
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,530
|
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 |
![]() |
![]() |
![]() |
#5 | Link |
Professional Code Monkey
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 |
![]() |
![]() |
![]() |
#7 | Link | |
Registered User
Join Date: Mar 2011
Posts: 4,787
|
Quote:
Cheers. |
|
![]() |
![]() |
![]() |
#8 | Link |
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. |
![]() |
![]() |
![]() |
#10 | Link | |
Registered User
Join Date: Mar 2011
Posts: 4,787
|
Quote:
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. |
|
![]() |
![]() |
![]() |
#11 | Link |
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. |
![]() |
![]() |
![]() |
#12 | Link |
Registered User
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)) Cu Selur |
![]() |
![]() |
![]() |
#13 | Link | |
Professional Code Monkey
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,530
|
Quote:
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet |
|
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|