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 > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 25th September 2023, 16:21   #81  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,898
There's a link for new a version dated 2023-09-26 in the opening post.
The major changes are listed above that link.
CropResize now comes in both Avisynth and VapourSynth flavours.
hello_hello is offline   Reply With Quote
Old 27th September 2023, 17:57   #82  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,898
Sorry about the quick update, but there's a link for new a version dated 2023-09-28 in the opening post.

Fixed a couple of regressions in version 2023-09-26.
There was a typo in the VapourSynth version preventing an output sample aspect ratio being used.
The Avisynth version was producing an error message when a copping preview was enabled while Info=true.

While I was updating I tweaked the way Info displays a frame properties sample aspect ratio of 1:1 so at first glance the source video doesn't appear to be anamorphic.
hello_hello is offline   Reply With Quote
Old 1st October 2023, 18:16   #83  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,898
There's a link for a new version dated 2023-10-02 in the opening post.

The "CropResize Changes" text file contains the details.
hello_hello is offline   Reply With Quote
Old 11th October 2023, 02:11   #84  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,898
There's a link for a new version dated 2023-10-11 in the opening post.

Fixed a minor bug in the VapourSynth version. The Avisynth version hasn't changed (only the date to keep the two flavours the same).
hello_hello is offline   Reply With Quote
Old 12th October 2023, 21:17   #85  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,898
Another minor bug fix. The Avisynth version this time. There's a link for the new version dated 2023-10-12 in the opening post.

Last edited by hello_hello; 12th October 2023 at 21:19.
hello_hello is offline   Reply With Quote
Old 28th October 2023, 22:14   #86  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,898
New version dated 2023-10-28 in the opening post.
The only change is a bug fix for one of the included resizer wrapper functions.
hello_hello is offline   Reply With Quote
Old 3rd April 2024, 09:38   #87  |  Link
rgr
Registered User
 
Join Date: Jun 2022
Posts: 95
If

Code:
cropresize(1920,1080,borders=true)
each source (jpg, mp4) will put in the box 1920x1080 with black frames?
Sources are:
- jpg files with different resolution and DAR, but each with PAR 1:1
- mp4, avi files with different resolutions and with 1:1 PAR (I think)

It seems to work, but I want to make sure

Last edited by rgr; 3rd April 2024 at 13:54.
rgr is offline   Reply With Quote
Old 6th April 2024, 14:06   #88  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,898
Quote:
Originally Posted by rgr View Post
If

Code:
cropresize(1920,1080,borders=true)
each source (jpg, mp4) will put in the box 1920x1080 with black frames?
Sources are:
- jpg files with different resolution and DAR, but each with PAR 1:1
- mp4, avi files with different resolutions and with 1:1 PAR (I think)

It seems to work, but I want to make sure
Yes, it'll work as you expect.
The difference between enabling borders and not enabling them...

When they're not enabled, the output dimensions determine the display aspect ratio (assuming there's no OutDAR or OutSAR specified). So for example, if the picture is 4:3 and you specify 16:9 output dimensions, the script will automatically increase the cropping if necessary to ensure the picture is cropped to 16:9 before it's resized. If you only specify a width or height though (not both), the script calculates the unspecified width or height instead of cropping.

When borders are enabled, the script adds borders instead of increasing the cropping so the DAR of the picture itself won't change.
You have to specify both a width and height to add borders, even when Borders=true.

Full disclosure....
Sometimes the picture has to be cropped a little to prevent aspect error before it's resized, as the resized picture must be at least mod2 for YV12 (the default is mod4), so even when borders are enabled the script might crop an extra pixel or two, but generally it's not any more than that.

Last edited by hello_hello; 6th April 2024 at 18:25.
hello_hello is offline   Reply With Quote
Old 9th April 2024, 18:10   #89  |  Link
rgr
Registered User
 
Join Date: Jun 2022
Posts: 95
Thanks.
I would also have a question about defining the source PAR, but since AviSynth does not support it, the problem does not exist
rgr is offline   Reply With Quote
Old 9th April 2024, 18:23   #90  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,435
Quote:
Originally Posted by rgr View Post
Thanks.
I would also have a question about defining the source PAR, but since AviSynth does not support it, the problem does not exist
SARNum , SARDen exist as a frame properties , so they can be set or overriden
http://avisynth.nl/index.php/Internal_functions#SARNum

Some source filters can read the source SAR and pass this information
automatically, some programs like ffmpeg can read avisynth frame properties and pass them along

Use PropShow to see the frame properties , propSet to set parameters
poisondeathray is offline   Reply With Quote
Old 10th April 2024, 21:04   #91  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,898
Quote:
Originally Posted by rgr View Post
Thanks.
I would also have a question about defining the source PAR, but since AviSynth does not support it, the problem does not exist
The current CropResize supports resizing based on a sample/pixel aspect ratio in frame properties (it uses any SAR in frame properties automatically). Not all source filters add a SAR to frame properties though. If for some reason you don't think that SAR is correct, you can over-ride it using the InDAR or InSAR arguments or use them to specify an input DAR/SAR when there's no SAR in frame properties. CropResize also writes and/or updates the SAR in frame properties after resizing. If you want a specific SAR after resizing, you can use the OutDAR or OutSAR arguments. Info=true will tell you the correct (output) SAR to use for encoding.

Keep in mind there can only be one output SAR per script, so even though you can specify a different OutDAR or OutSAR when there's more than one instance of CropResize in a script (when appending different videos), it doesn't make sense to do so.
If you need to change the way CropResize crops and resizes based on an aspect ratio, change the InDAR or InSAR instead.

Ignore a chroma location being shown in this screenshot. It's something I'm adding for the next version, mainly for color conversion, although it's turned into more of a chore than I expected.

A random anamorphic source, resized to PAL 16:9 dimensions with borders.

CropResize(720,576, OutDAR=16.0/9.0, Borders=true, Info=true)



An example where videos A and B both have a SAR in frame properties but you want to change it for video B. Both are resized to non-anamorphic (square pixel) dimensions.

A = FFVideoSource("VideoA")
B = FFVideoSource("VideoB")

A.Trim(0, 99).CropResize(1280,720, Borders=true) ++ \
B.Trim(60, 154).CropResize(1280,720, InSAR=64.0/45.0, Borders=true) ++ \
A.Trim(100, 0).CropResize(1280,720, Borders=true)

Last edited by hello_hello; 10th April 2024 at 21:35.
hello_hello is offline   Reply With Quote
Old 10th April 2024, 23:03   #92  |  Link
rgr
Registered User
 
Join Date: Jun 2022
Posts: 95
Quote:
Originally Posted by poisondeathray View Post
some programs like ffmpeg can read avisynth frame properties and pass them along

Use PropShow to see the frame properties , propSet to set parameters
I tested ffmpeg and I don't see it reading PAR.

Code:
  Duration: 03:04:24.12, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p(tv, bt470bg/bt470bg/smpte170m, progressive), 696x560, 50 fps, 50 tbr, 50 tbn
  Stream #0:1: Audio: pcm_f32le, 48000 Hz, stereo, flt, 3072 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (pcm_f32le (native) -> aac (native))
Maybe LWLibavVideoSource doesn't set SAR.

Last edited by rgr; 10th April 2024 at 23:10.
rgr is offline   Reply With Quote
Old 10th April 2024, 23:06   #93  |  Link
rgr
Registered User
 
Join Date: Jun 2022
Posts: 95
Quote:
Originally Posted by hello_hello View Post
The current CropResize supports resizing based on a sample/pixel aspect ratio in frame properties (it uses any SAR in frame properties automatically). Not all source filters add a SAR to frame properties though. If for some reason you don't think that SAR is correct, you can over-ride it using the InDAR or InSAR
Good to know, thanks for explaining.
I am combining various video files and if PAR is not recognized automatically, I will not do it manually for now.
rgr is offline   Reply With Quote
Old 10th April 2024, 23:17   #94  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,435
Quote:
Originally Posted by rgr View Post
I tested ffmpeg and I don't see it reading PAR.

Code:
  Duration: 03:04:24.12, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p(tv, bt470bg/bt470bg/smpte170m, progressive), 696x560, 50 fps, 50 tbr, 50 tbn
  Stream #0:1: Audio: pcm_f32le, 48000 Hz, stereo, flt, 3072 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (pcm_f32le (native) -> aac (native))
Maybe LWLibavVideoSource doesn't set SAR.


It might not be automatic in the current avs ffmpeg patch. Youu can add "-avisynth_flags sar " as an ffmpeg input option

See this post

Quote:
FFmpeg now supports reading two more frame properties - _SARNum and _SARDen, which are then combined into what FFmpeg reads as the full SAR value.
https://forum.doom9.org/showthread.p...49#post1974149


Code:
colorbars(720,480,"YV12")
Trim(0,300)
propSet("_SARNum",10)
propSet("_SARDen",11)
Quote:
Input #0, avisynth, from 'props.avs':
Duration: 00:00:10.04, start: 0.000000, bitrate: 0 kb/s
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 720x480, SAR 10:11
DAR 15:11, 29.97 fps, 29.97 tbr, 29.97 tbn
Stream #0:1: Audio: pcm_f32le, 48000 Hz, 2 channels, flt, 3072 kb/s
At least one output file must be specified
poisondeathray is offline   Reply With Quote
Old 11th April 2024, 10:25   #95  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,898
Quote:
Originally Posted by rgr View Post
Good to know, thanks for explaining.
I am combining various video files and if PAR is not recognized automatically, I will not do it manually for now.
Why not?

When you specify an InDAR or InSAR, CropResize uses it as the basis for it's calculations. You don't need to specify either for a non-anamorphic source, but if the source is anamorphic the correct InDAR or InSAR should be specified if there's no SAR in frame properties.

If you were to specify a 16:9 DAR for an NTSC source (for example), you could resize it to 16:9 dimensions without CropResize applying any extra cropping.

CropResize(960,540, InDAR=16.0/9.0)

Without the InDAR, CropResize would assume 720x480 is both the resolution and the display aspect ratio (1.5:1) and it'll therefore crop unnecessarily to make the video 16:9 before resizing, and the DAR of the picture after resizing will be incorrect.

It's important that the correct InDAR or InSAR is used for an anamorphic source.

Last edited by hello_hello; 12th April 2024 at 02:44.
hello_hello 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 07:52.


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