Resolution Calculation

Archive of historical development discussions
Discussions / Development has moved to GitHub
Forum rules
*******************************
Please be aware we are now using GitHub for issue tracking and feature requests.
- This section of the forum is now closed to new topics.

*******************************
Post Reply
User avatar
s55
HandBrake Team
Posts: 10360
Joined: Sun Dec 24, 2006 1:05 pm

Resolution Calculation

Post by s55 »

one thing my windows GUI needs is resolution calculation which takes into account cropping etc. (Incorporating it into v2)


Source 720x572 DVD which is aspect 1.33 i believe

Can someone show me that maths to work out the height based on whats entered for the width.

I just want to make sure i have this totally clear in my head b4 i get it totally wrong.
jbrjake
Veteran User
Posts: 4805
Joined: Wed Dec 13, 2006 1:38 am

Re: Resolution Calculation

Post by jbrjake »

sr55 wrote:one thing my windows GUI needs is resolution calculation which takes into account cropping etc. (Incorporating it into v2)


Source 720x572 DVD which is aspect 1.33 i believe

Can someone show me that maths to work out the height based on whats entered for the width.
I'm guessing you're looking for more than just:

Height = Width after cropping / Aspect Ratio

?

Lots of related stuff in hb_set_size() in hb.c...
User avatar
s55
HandBrake Team
Posts: 10360
Joined: Sun Dec 24, 2006 1:05 pm

Post by s55 »

Right, take 720x576 for example

720/1.33 = 541.3
720/1.25 = 576

I think you see why i'm a little confused.

Thats quite a drop...


I'll go have a look at that source file see how its doing it.
jbrjake
Veteran User
Posts: 4805
Joined: Wed Dec 13, 2006 1:38 am

Post by jbrjake »

sr55 wrote:Right, take 720x576 for example

720/1.33 = 541.3
720/1.25 = 576

I think you see why i'm a little confused.

Thats quite a drop...
Remember: just because the image is stored on the DVD in a 720*576 frame doesn't mean its native aspect ratio is 720/576...all PAL DVD frames are 720*576 no matter if the content is 4:3 or 16:9. If it's 16:9, it keeps the vertical resolution and is squished horizontally. If it's 4:3, it keeps the horizontal resolution and is stretched vertically. So you want to reduce the height from 576 to 544 to get rid of that vertical stretching and recreate the actual 4:3 display ratio.
User avatar
s55
HandBrake Team
Posts: 10360
Joined: Sun Dec 24, 2006 1:05 pm

Post by s55 »

I suspect i'm going to have to do alot of testing after I've written this code :/
johnallen
Experienced
Posts: 95
Joined: Sat Sep 30, 2006 8:52 pm

Post by johnallen »

sr55,

libhb can actually do some of the auto matic cropping and calculations for you. The method of interest is hb_set_size.

Take a look at IHB in the ExpressController.mm file. Look for the method called convertGo. I use hb_set_size to crop the output based on the max picture width and the aspect the user has choosen. You might be able to make use of this as well.
mirkwood
Experienced
Posts: 83
Joined: Mon Jan 01, 2007 7:50 pm

Post by mirkwood »

sr55,

Since your GUI is using HBTest.exe and you're not directly using libhb, why are you trying to size calculations in your GUI?

HBTest.exe (libhb) is capable of figuring out the needed cropping and resizing, and generally it works well. If you want to rip the movie to full size, then don't specify any -w or -l options to HBTest.exe, and the resizing and cropping be automatically figured out. Sometimes this results in the movie actually being horizontally smaller than the source though, even if there aren't any black bars to crop off on the left or right side of the frame. But generally it's not a big loss.
Post Reply