VideoHelp Forum

+ Reply to Thread
Results 1 to 11 of 11
Thread
  1. Hi, I'm trying to set up a script that will resize my video to 720 pixels wide and then proportionally resize the height automatically based on mod4.

    So if my source is 1920x1080 the result would be 720x404 and if my source is 1920x800 it would be 720x300.

    Any ideas how do so this? I tried adding math into the script using mod operators, but then it got too confusing since I'm not a math wiz.
    Last edited by syrist; 25th Apr 2020 at 13:33.
    Quote Quote  
  2. Look for the CropResize script by hello_hello, works like a charm.
    Quote Quote  
  3. Note that 404 and 300 are mod4, not mod8.

    To get a mod8 siz caluculate a height then divide by 8, and multiply by 8. To get a rounded height calculate the height add 4 (half the modulus), then divide by 8 and multiply by 8.

    Code:
    Spline36Resize(720,  ((720 * height / width) + 4) / 8 * 8)
    Or as a function:

    Code:
    function ResizeToWidth(clip v, int width, int "modulus")
    {
        modulus = default(modulus, 4) # default to mod4 if not specified
        Spline36Resize(v, width,  ((width * v.height / v.width) + modulus/2) / modulus * modulus)
    }
    call with:

    Code:
    ResizeToWidth(720, 8)
    Last edited by jagabo; 25th Apr 2020 at 13:43.
    Quote Quote  
  4. Originally Posted by jagabo View Post
    Note that 404 and 300 are mod4, not mod8.

    To get a mod8 siz caluculate a height then divide by 8, and multiply by 8. To get a rounded height calculate the height add 4 (half the modulus), then divide by 8 and multiply by 8.
    Oops... I meant 4. I'll edit post, thanks.
    Quote Quote  
  5. Originally Posted by amaipaipai View Post
    Look for the CropResize script by hello_hello, works like a charm.
    Wow, this looks great. I'll check it out thanks.
    Quote Quote  
  6. Note I added some quick examples to my last post.
    Quote Quote  
  7. Originally Posted by jagabo View Post
    Note I added some quick examples to my last post.
    Thank you, this is exactly what I was looking for.
    Quote Quote  
  8. The advantage of using CropResize is if the new width and height don't match the original aspect ratio, it'll crop a little from the width or height (whatever is required) to prevent aspect error. The default is mod4 so if you want to resize the width to 720 with a mod4 height, and the source is not anamorphic and you don't want to specify any cropping, all you need to specify is the new width.

    CropResize(720)

    If you're resizing by a large amount I'd recommend using the Resize8 function for resizing, as it corrects the slight chroma shift caused by Avisynth's resizers (the more you resize the larger the shift). You can use it this way.

    CropResize(720, Resizer="Resize8")

    There's also an included script named "CropResize Resizer Functions". It includes a wrapper function for Resize8 that's easily edited so Resize8 will use your preferred options, such as your preferred resizing method. The Resize8 script is still required. You use it this way.

    CropResize(720, Resizer="CR_Resize8")

    Or you can also use one of the "CropResize Wrapper Functions" to call an alternative resizer (if that script is loaded) by adding an X to the end of the function name. The default alternative resizer is Resize8 (the help file tells you how to change that).

    CropResizeX(720) uses Resize8 for resizing by default.

    For 16:9 have you considered a width of 704 rather than 720?
    704x396 is exactly 16:9 and mod4, whereas 720x404 is close to, but not quite 16:9.

    CropResize(704,396) would force the script to crop the source to exactly 16:9 before resizing.
    Last edited by hello_hello; 26th Apr 2020 at 07:40.
    Quote Quote  
  9. Originally Posted by hello_hello View Post
    The advantage of using CropResize is if the new width and height don't match the original aspect ratio, it'll crop a little from the width or height (whatever is required) to prevent aspect error. The default is mod4 so if you want to resize the width to 720 with a mod4 height, and the source is not anamorphic and you don't want to specify any cropping, all you need to specify is the new width.

    CropResize(720)

    If you're resizing by a large amount I'd recommend using the Resize8 function for resizing, as it corrects the slight chroma shift caused by Avisynth's resizers (the more you resize the larger the shift). You can use it this way.

    CropResize(720, Resizer="Resize8")

    There's also an included script named "CropResize Resizer Functions". It includes a wrapper function for Resize8 that's easily edited so Resize8 will use your preferred options, such as your preferred resizing method. The Resize8 script is still required. You use it this way.

    CropResize(720, Resizer="CR_Resize8")

    Or you can also use one of the "CropResize Wrapper Functions" to call an alternative resizer (if that script is loaded) by adding an X to the end of the function name. The default alternative resizer is Resize8 (the help file tells you how to change that).

    CropResizeX(720) uses Resize8 for resizing by default.

    For 16:9 have you considered a width of 704 rather than 720?
    704x396 is exactly 16:9 and mod4, whereas 720x404 is close to, but not quite 16:9.

    CropResize(704,396) would force the script to crop the source to exactly 16:9 before resizing.
    Thanks for the info hello_hello. This works great... it's just as fast as LanczosResize plus is produces slightly smaller file sizes. So this is what I'm going to use for all my future projects that involve re-scaling.

    As for 720 vs 704... I think I would prefer the extra bit of resolution than having a perfectly matched 16x9 aspect ratio. 720 is what the scene uses for SD content plus I'm used to 720 representing SD from the DVD authoring days.
    Last edited by syrist; 26th Apr 2020 at 09:42.
    Quote Quote  
  10. Originally Posted by syrist View Post
    Hi, I'm trying to set up a script that will resize my video to 720 pixels wide and then proportionally resize the height automatically based on mod4.

    So if my source is 1920x1080 the result would be 720x404 and if my source is 1920x800 it would be 720x300.

    Any ideas how do so this? I tried adding math into the script using mod operators, but then it got too confusing since I'm not a math wiz.
    You can do this with ffmpeg using its scale filter like -vf "scale 720:-4". It will resize the width to 720 and scale the height by keeping the original aspect ratio within mod 4.
    Quote Quote  
  11. Originally Posted by syrist View Post
    Thanks for the info hello_hello. This works great... it's just as fast as LanczosResize plus is produces slightly smaller file sizes. So this is what I'm going to use for all my future projects that involve re-scaling.
    In case you haven't read the whole help file yet (there's a lot of it) Spline36Resize is the default resizing. If you specify the Resize8 script, it's defaults are Spline36Resize for upscaling and Lanczos4Resize for downscaling (I'm pretty sure) but you can use the included wrapper function and change that if you prefer.

    Originally Posted by syrist View Post
    As for 720 vs 704... I think I would prefer the extra bit of resolution than having a perfectly matched 16x9 aspect ratio. 720 is what the scene uses for SD content plus I'm used to 720 representing SD from the DVD authoring days.
    Of course it's up to you, but if you can see a detail difference between 704x396 & 720x404 I think you might have bionic eyes.

    Back in the days of Xvid I used to compare the two for non 16:9 sources to see which resulted in the most picture being cropped to prevent aspect error. Sometimes a 720 width would require more cropping (often from the width, so 704 could result in the same or a greater height), but what you may have lost in resolution with a 704 width you sometimes made up for by retaining some extra picture. Admittedly that was back in the days of mod16 so it's probably not very relevant now.

    If you're not married to a 720 width, I think 768x432 is the next exact 16:9, mod4 resizing "up" from there. A width of 720 seems a bit miserly these days. Especially when you consider the display dimensions of a 16:9 DVD if you stretch the width rather than reduce the height for "square pixel" dimensions. 1024x576 or 852x480. Not that I've paid much attention, but I think for x264 encoding, 576p and 480p are quite common for the scene now (implying a width of 1024 or 852 after cropping the black and resizing, the same way 720p implies a width of 1280). Each to their own though....
    Last edited by hello_hello; 26th Apr 2020 at 15:00.
    Quote Quote  



Similar Threads