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
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 2nd December 2009, 20:14   #1  |  Link
SVD
Registered User
 
Join Date: Mar 2007
Posts: 5
Cropping a 1080p YV12 source to mod8 height

I have a 1920x1080 blu-ray source which has black borders top and bottom:
137px at the top and -139px at the bottom.

I wanted to crop both values with Crop(0,137,-0,-139) and then use AddBorders(0,2,0,2) to add 2px at the top and bottom to end up with a mod8 compatible height of 808px.
This is was not possible.
AviSynth told me it's only possible to crop even numbers. I tried cropping 136px top and -138px bottom. This would result in 806px including a 1px border top and bottom. To achieve 808px I tried AddBorders(0,1,0,1) to get a resolution of 1920x808 including a 2px border top and bottom.
There was no AviSynth error but I ended up with an image of 1920x808 which had 1px black at top and 3px black at the bottom. I'm sure the AddBorders syntax is correct.

What's wrong then?
SVD is offline   Reply With Quote
Old 2nd December 2009, 20:35   #2  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Adding an odd-sized border to a YV12 clip would require resampling the chroma, so Avisynth doesn't do it. It silently rounds the borders to even numbers, rounding down for the top and left, and up for the bottom and right. So 1 and 1 become 0 and 2.

Maybe it would be better for it to report an error instead (as in Crop)?

Last edited by Gavino; 2nd December 2009 at 21:22. Reason: perhaps report error?
Gavino is offline   Reply With Quote
Old 2nd December 2009, 22:54   #3  |  Link
Alex_ander
Registered User
 
Alex_ander's Avatar
 
Join Date: Apr 2008
Location: St. Petersburg, Russia
Posts: 334
Not sure what happens to chroma here, but cropping must work:

Spline36Resize(1920,804,0,137,0,-139).AddBorders(0,2,0,2)
Alex_ander is offline   Reply With Quote
Old 2nd December 2009, 23:12   #4  |  Link
Keiyakusha
契約者
 
Keiyakusha's Avatar
 
Join Date: Jun 2008
Posts: 1,576
Quote:
Originally Posted by Alex_ander View Post
Not sure what happens to chroma here, but cropping must work:

Spline36Resize(1920,804,0,137,0,-139).AddBorders(0,2,0,2)
But this does resizing. If SVD wanted to crop black borders, its probably better just overcrop (or undercrop) by 1px instead of resampling the whole thing...
EDIT: In this case (if resizing is OK) its better to do Spline36Resize(1920,808,0,137,0,-139) without any borders...

Last edited by Keiyakusha; 2nd December 2009 at 23:18.
Keiyakusha is offline   Reply With Quote
Old 2nd December 2009, 23:31   #5  |  Link
SVD
Registered User
 
Join Date: Mar 2007
Posts: 5
I don't want to resize so I guess I'm going with Crop(0, 140, -0, -140). This overcrops 3px top and 1px bottom. Is this to be considered a really bad overcrop or common practice in such a case?
SVD is offline   Reply With Quote
Old 2nd December 2009, 23:38   #6  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by Keiyakusha View Post
In this case (if resizing is OK) its better to do Spline36Resize(1920,808,0,137,0,-139) without any borders...
That will resample both luma and chroma, whereas Spline36Resize(1920,804,0,137,0,-139) will only resample chroma and copy luma.
Gavino is offline   Reply With Quote
Old 2nd December 2009, 23:41   #7  |  Link
Inspector.Gadget
Registered User
 
Join Date: May 2008
Posts: 1,618
Quote:
Is this to be considered a really bad overcrop or common practice in such a case?
Are you going to miss 4 lines of vertical resolutions? If so, are you going to be bothered by 4px of black/soft borders? This is entirely up to you. You'll get great advice here on the technical side of things, but this is an aesthetic question only you can answer.

FWIW, a lot of Blu-ray discs have sharpening artifacts near the picture edges...if me mentioning this curses you with noticing them now (haha), maybe you want to crop those out too and you may end up with a mod8 resolution with no "good" areas thrown away.
Inspector.Gadget is offline   Reply With Quote
Old 2nd December 2009, 23:45   #8  |  Link
Keiyakusha
契約者
 
Keiyakusha's Avatar
 
Join Date: Jun 2008
Posts: 1,576
Quote:
Originally Posted by Gavino View Post
That will resample both luma and chroma, whereas Spline36Resize(1920,804,0,137,0,-139) will only resample chroma and copy luma.
Yep, you right. But who knows, maybe its still better because absence of black borders will helps compression.
Keiyakusha is offline   Reply With Quote
Old 2nd December 2009, 23:51   #9  |  Link
SVD
Registered User
 
Join Date: Mar 2007
Posts: 5
Quote:
Originally Posted by Inspector.Gadget View Post
Are you going to miss 4 lines of vertical resolutions? If so, are you going to be bothered by 4px of black/soft borders? This is entirely up to you. You'll get great advice here on the technical side of things, but this is an aesthetic question only you can answer.

FWIW, a lot of Blu-ray discs have sharpening artifacts near the picture edges...if me mentioning this curses you with noticing them now (haha), maybe you want to crop those out too and you may end up with a mod8 resolution with no "good" areas thrown away.
Hehe, yes, I see them in the 1st and last line of the actual picture. Leaves me cropping 2 px of the image. Well if non-present black borders help the compression I can live with that. Thanks for the advice.
SVD is offline   Reply With Quote
Reply


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 21:32.


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