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.

 Doom9's Forum Crop and Recalculate Resize Dimensions
 User Name Remember Me? Password
 Register FAQ Calendar Search Today's Posts Mark Forums Read

 Thread Tools Search this Thread Display Modes
 10th December 2014, 18:39 #1  |  Link MysteryX Soul Architect     Join Date: Apr 2014 Posts: 2,349 Crop and Recalculate Resize Dimensions I have VCD videos in 352x288 format with a DAR of 4:3 and PAR of 12:11 I currently do something like this which works great smoothD2c(12, ncpu=4) eedi3_rpow2 (2) nnedi3_rpow2 (2) Spline36Resize(960, 720) Now, what if I want to crop black borders in the video? I could add this: Crop(2,40,-2,-40) Problem is that the Resize width won't be 960 anymore. I would need to calculate the proper width based on crop settings. What would be the best way to 1) facilitate finding which crop settings are valid (it says it must be dividable by 4) 2) calculate the proper width for the resize function Last edited by MysteryX; 24th June 2015 at 06:29.
 10th December 2014, 20:07 #2  |  Link Asmodian Registered User   Join Date: Feb 2002 Location: San Jose, California Posts: 4,265 SAR × PAR = DAR 352/288 * 12/11 = 4/3 720 * (4/3) = 960 Plug in the new numbers for resolution. Take the new DAR and multiply it by 720. (edit: round to the closest even number) SAR = signal aspect ratio PAR = pixel aspect ratio DAR = display aspect ratio Last edited by Asmodian; 10th December 2014 at 20:12.
 10th December 2014, 20:10 #3  |  Link hello_hello Registered User   Join Date: Mar 2011 Posts: 4,520 Try the Yoda Resize Calculator. It's an exe but it's safe. You set the input resolution and/or aspect ratio along with your desired cropping and resizing, and It'll calculate the aspect ratio distortion for you. I just fiddle with the cropping and/or resizing a bit until the distortion is at a minimum. Sometimes keeping it close to zero means cropping a few pixels from the picture somewhere. According to the calculator you could resize to 960x526 after the cropping you specified. The calculator will apply mod1 cropping, but the AVIsynth crop function works in increments of two. If you're like me, and a little OCD at times, you can use the resize filter to apply extra mod1 cropping to the video (in case you weren't aware). If, for example (I'm just making up numbers at the moment), ideally you'd like to reduce the aspect ratio distortion by cropping 3 pixels from the left instead of 2, and 41 from the bottom rather than 40, you can do it this way: Crop(2,40,-2,-40) Spline36Resize(960,526,1,0,0,-1) Although if you're cropping first, then upscaling with nnedi3 and resizing, don't forget to account for the upscaling if you use the resize filter to crop. I'm a bit silly and it tends to confuse me, but if you double the size of the video after the initial cropping, then you'd need to double any resize filter cropping too. So to crop the original video by 3 pixels left, and 2 right, 40 top and 41 bottom, you'd need to do it like this if nnedi3_rpow2 (2) is in the middle. Crop(2,40,-2,-40) nnedi3_rpow2 (2) Spline36Resize(960,526,2,0,0,-2) Last edited by hello_hello; 10th December 2014 at 20:38.
 10th December 2014, 21:40 #4  |  Link MysteryX Soul Architect     Join Date: Apr 2014 Posts: 2,349 I designed this cropping script that works pretty well Code: ```SrcHeight = 288 SrcWidth = 352 SrcAR = 12 / 11 # Source cropping (must divide by 4) CropLeft = 6 CropTop = 2 CropRight = 2 CropBottom = 2 # Output cropping (pixel-precision) Crop2Left = 2 Crop2Top = 8 Crop2Right = 6 Crop2Bottom = 4 CropHeight = ((SrcHeight - CropTop - CropBottom) * 4) - Crop2Top - Crop2Bottom CropWidth = ((SrcWidth - CropLeft - CropRight) * 4) - Crop2Left - Crop2Right ResizeHeight = 720 ResizeWidth = Round(Float(CropWidth) * SrcAR / CropHeight * ResizeHeight / 2) * 2 Crop(CropLeft, CropTop, -CropRight, -CropBottom) smoothD2c(12, ncpu=4) eedi3_rpow2 (2) nnedi3_rpow2 (2) Spline36Resize(ResizeWidth, ResizeHeight, Crop2Left, Crop2Top, -Crop2Right, -Crop2Bottom)``` Although doing cropping at the end could do the job by itself, cropping first increases performance. Can there be any quality impact to doing resizing in such a way? Last edited by MysteryX; 24th June 2015 at 06:28.
 10th December 2014, 21:48 #5  |  Link StainlessS HeartlessS Usurer     Join Date: Dec 2009 Location: Over the rainbow Posts: 9,501 Do not crop before Deblock (which I think smoothD2c is doing). EDIT: Deblock-ing relies upon block boundaries being at known positions, cropping will change that and negatively impact results (unless all cropping done in multiples of block size, both H & V). Better to leave out deblocking altogether than deblock in wrong position, making things worse. __________________ I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 10th December 2014 at 21:58.
10th December 2014, 21:52   #6  |  Link
MysteryX
Soul Architect

Join Date: Apr 2014
Posts: 2,349
Quote:
 Originally Posted by StainlessS Do not crop before Deblock (which I think smoothD2c is doing).
Oh thanks! I thought blocking was pretty bad, hence my question about quality.

Last edited by MysteryX; 24th June 2015 at 06:28.

 Tags avisynth, crop, resize

 Thread Tools Search this Thread Search this Thread: Advanced Search Display Modes Linear Mode

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements and Chat     General Discussion     News     Forum / Site Suggestions & Help General     Decrypting     Newbies     DVD2AVI / DGIndex     Audio encoding     Subtitles     Linux, Mac OS X, & Co Capturing and Editing Video     Avisynth Usage     Avisynth Development     VapourSynth     Capturing Video     DV     HDTV / DVB / TiVo     NLE - Non Linear Editing     VirtualDub, VDubMod & AviDemux     New and alternative a/v containers Video Encoding     (Auto) Gordian Knot     MPEG-4 ASP     MPEG-4 Encoder GUIs     MPEG-4 AVC / H.264     High Efficiency Video Coding (HEVC)     New and alternative video codecs     MPEG-2 Encoding     VP9 and AV1 (HD) DVD, Blu-ray & (S)VCD     One click suites for DVD backup and DVD creation     DVD & BD Rebuilder     (HD) DVD & Blu-ray authoring     Advanced authoring     IFO/VOB Editors     DVD burning Hardware & Software     Software players     Hardware players     PC Hard & Software Programming and Hacking     Development     Translations

All times are GMT +1. The time now is 09:55.

 Doom9.org - Archive - Top