Feature Request: Add Option "Keep Aspect Ratio"

Free video converter, convert from any format to any format, mkv to avi, m2ts to avi, mp4, h264, mts, wmv, mov, DVD, etc.

Moderators: Maggie, ckhouston, JJ, Phil, alexia, Forum admin

Suse18
Posts: 6
Joined: Mon Oct 06, 2014 10:07 am

Feature Request: Add Option "Keep Aspect Ratio"

Post by Suse18 »

I am trying to convert a HD TV movie recording (MPEG-TS, AVC 1280x720 16:9) to PAL DVD 16:9.
The movie was broadcasted in true letterbox format in a 16:9 frame, that is has black bars on top and bottom and left and right.
When using the advanced feature to "Remove Black Bars" it only removes the top and bottom black bars by adding crop values for bottom and top resulting in a useless strechted output.
To retain the Original Aspect Ratio I need to estimate (don't know how calculate exactly?) the correct values for left and right cropping and add them accordingly, which may result in still incorrect aspect ratio.

There should be an option box like "KEEP ASPECT RATIO" which automatically retains the correct Aspect Ratio by adjusting left and right crop values when REMOVE BLACK BARS ist used and option is enabled.

Please consider. Thanks.
Copnm
Posts: 322
Joined: Sat Nov 12, 2011 7:46 am
Location: Brooklyn, NY

Re: Feature Request: Add Option "Keep Aspect Ratio"

Post by Copnm »

Hello Suse18,

You are cropping the bottom and top only. That itself is changing the aspect ratio. If you want to keep it, you have to crop the sides as well.

I recommend using letterbox, as it keeps the format you are trying to use.

Thanks for reading,
Neil M
ALWAYS search the forums and read announcements. They will most likely have the answer(s) you are looking for.
ckhouston
VSO Fanatic
Posts: 4590
Joined: Wed Aug 08, 2007 4:12 am

Re: Feature Request: Add Option "Keep Aspect Ratio"

Post by ckhouston »

To retain the Original Aspect Ratio I need to estimate (don't know how calculate exactly?) the correct values for left and right cropping and add them accordingly, which may result in still incorrect aspect ratio.
There are equations in Calculating Crop/Pad Values for the Video Resize Editor in the Guides + Manuals forum that you can use to prevent distortion.

However the Pan-Scan option in Video Converter may do what you want. I prefer to leave it at Letterbox and use the zoom function on my TV remote if I don't want to see black bars.
Suse18
Posts: 6
Joined: Mon Oct 06, 2014 10:07 am

Re: Feature Request: Add Option "Keep Aspect Ratio"

Post by Suse18 »

Thanks very much for the replies and the tips. Unfortunately they do not solve my problem as my LCD TV (as probably many others do not allow to zoom in on my HDMI connected DVD player) therefore would like to crop the black bars as much as possible with the VSO Video Converter (actually that is the reason I bought the software) while keeping the correct aspect ratio. As result the video will be zoomed in within the unchanged 16:9 frame. Pan-And-Scan is not really an option as it deletes part of the picture horizontally. I will take a closer look at the formulas later but at first sight I do not see how they solve this problem as the source and the target frame remains to be at 16:9.

To make it more clear I will insert 3 screenshots:
1. Original unchanged source frame.
2. Result after pressing "Remove black bars" = Distorted picture as horizontal crop values remain at 0. I request that the program should automatically add correct horizontal crop values to keep the proper aspect ratio when the requested option box is checked.
3. Desired result after I manually added estimated horizontal crop values by try and error method = Looks OK but not sure if it is the correct Aspect ratio.
Attachments
1. Original unchanged source frame.
1. Original unchanged source frame.
2. Result after pressing "Remove black bars" = Distorted picture as horizontal crop values remain at  0. I request that the program should automatically add correct horizontal crop values to keep the proper aspect ratio when the requested option box is checked.
2. Result after pressing "Remove black bars" = Distorted picture as horizontal crop values remain at 0. I request that the program should automatically add correct horizontal crop values to keep the proper aspect ratio when the requested option box is checked.
3. Desired result after I manually added estimated horizontal crop values by try and error method = Looks OK but not sure if it is the correct Aspect ratio.
3. Desired result after I manually added estimated horizontal crop values by try and error method = Looks OK but not sure if it is the correct Aspect ratio.
User avatar
cedric
VSO Team Member
Posts: 1374
Joined: Fri May 02, 2008 9:31 am
Location: Toulouse-FRANCE

Re: Feature Request: Add Option "Keep Aspect Ratio"

Post by cedric »

Hello Suse18,

There's 2 different cases where "remove black bars" option can be applied:

- The output resolution is not set ("same resolution as source")
In this case, using remove black bars function will adjust top/bottom crop values AND output resolution.
For example: you have a 1920x1080 input file containing video with black bars.
* If you dont use the remove BB function , the output file will be 1920x1080 and black bars will be encoded.
* If you use the remove BB function, the computed crop values will ve used to adjust output resolution (Ex: if your video file contain a 1.85 AR video, the output file final resolution will be 1920x1038)

- The output resolution is set/forced (DVD-Video, Blu-ray video) your case...
In this case, using remove BB will adjust top/bottom crop values but (like output resolution can't be changed), the video will be streched.
So, I need to update the code to adjust left/right crop values to keep aspect ratio. That mean video part can be lost. (This function could be called "auto pan-scan")

This change will be added in last version...

Thank you for your feedback.

Regards,
Suse18
Posts: 6
Joined: Mon Oct 06, 2014 10:07 am

Re: Feature Request: Add Option "Keep Aspect Ratio"

Post by Suse18 »

Hello Cedrick,
many thanks and am looking forward to the new function to remove BB while maintaining AR for correct DVD/BD output resolution.

To make sure I understand you correctly: In my example the new function you described would NOT result in lost video on left/right sides, because the AR is 1.66 thus the BB on top/bottom are smaller than on left/right. After applying the new function there should be no more BB on top/bottom and small BB on left/right.

You are probably referring to cases where the top/bottom BB are larger than the BB on left/right i.e. AR 2.00 or 2.35 etc (AR greater than 1.85). In these cases removing ALL the top/bottom BB would of course result in loss of video on left/right. To prevent any highly unwanted loss of video, I would suggest that the new function should be limited to remove BB on all edges (while maintaining AR) only until the point where loss of video occurs. This way the output result would be optimized without destroying any video and there could be remaining BB on top/bottom or left/right depending of the original AR but never on all 4 edges.

Maybe , if you agree to my request, you could also name the new function it a little differently, since pan&scan would indeed indicate that there could be loss of video involved, maybe "auto-zoom"

Regards
User avatar
cedric
VSO Team Member
Posts: 1374
Joined: Fri May 02, 2008 9:31 am
Location: Toulouse-FRANCE

Re: Feature Request: Add Option "Keep Aspect Ratio"

Post by cedric »

Hello Suse18,

You're right, you should not loose any part of video in your case.
But for video having black bars on top and bottom only, right and left parts will be lost.

Good suggestion to "limit" the auto crop function when at least 2 black bars (top/bottom OR left/right) were found.
Will check if I can add this for next version (but vertical scan take more time to code than horizontal one)

Thank you.
ckhouston
VSO Fanatic
Posts: 4590
Joined: Wed Aug 08, 2007 4:12 am

Re: Feature Request: Add Option "Keep Aspect Ratio"

Post by ckhouston »

Suse18 wrote:3. Desired result after I manually added estimated horizontal crop values by try and error method = Looks OK but not sure if it is the correct Aspect ratio.
You got close by trial and error adjustment.

The Remove black bars button cropped 74 pixels top and bottom. Use equation 7 in http://forums.vso-software.fr/post45951.html#p45951 to find the correct amount to crop the sides. Since SAR and TAR are equal in your case, the equation reduces to CHP = (SHP/SVP) x CVP. Substituting values into it gives CHP = (1280/720) x (74) = 132.

So cropping 74 pixels top and bottom and 132 pixels on both sides should give no distortion.
Suse18
Posts: 6
Joined: Mon Oct 06, 2014 10:07 am

Re: Feature Request: Add Option "Keep Aspect Ratio"

Post by Suse18 »

Hello ckhouston,
many thanks for your explanations and the correct value. Will use it and hope for automatic calculation in future release.
ckhouston
VSO Fanatic
Posts: 4590
Joined: Wed Aug 08, 2007 4:12 am

Re: Feature Request: Add Option "Keep Aspect Ratio"

Post by ckhouston »

I think I may have an error in my equations. So hold up until I get back, may be tomorrow.
User avatar
cedric
VSO Team Member
Posts: 1374
Joined: Fri May 02, 2008 9:31 am
Location: Toulouse-FRANCE

Re: Feature Request: Add Option "Keep Aspect Ratio"

Post by cedric »

Feature request added in last beta version (1.5.0.10)...

Regards,
ckhouston
VSO Fanatic
Posts: 4590
Joined: Wed Aug 08, 2007 4:12 am

Re: Feature Request: Add Option "Keep Aspect Ratio"

Post by ckhouston »

Hey cedric. I tried the Remove black bars feature in 1.5.0.10 with a 2.25 AR, 720x320 mp4 file converted to 16:9 NTSC DVD.

Images from the video editing window are attached. The first one shows that 76 horizontal pixels are needed to be cropped from each side with the Pan_Scan Fit method in order to fit the video to the screen vertically. It also shows that the source has small black bars top and bottom. I measure those bars as 4 pixels tall while the second image shows a crop of 5 pixels when the Remove black bars feature is used which removes part of the red lines. That is not important though, what is important is the 5 pixel vertical crop combined with the 98 pixel horizontal crop changes the aspect of the rectangle from slightly less than 1.0 to more than 1.0. Manually changing that 98 pixel horizontal crop to 85 (that I calculate) changes the aspect of the rectangle back to what it should be, as shown in the third image.
Attachments
Pan-Scan.jpg
Remove black bars.jpg
Remove black bars manually adjusted..jpg
User avatar
cedric
VSO Team Member
Posts: 1374
Joined: Fri May 02, 2008 9:31 am
Location: Toulouse-FRANCE

Re: Feature Request: Add Option "Keep Aspect Ratio"

Post by cedric »

Hello ckhouston,

Is your "720x320 mp4 file" anamorphic?
The pad/crop values are applied on the original video area (720x576 for a PAL video), not the resized one (using SAR, so 720x540 for 4/3).
The pad/crop values must take input SAR in account. But if your input file SAR = 1, the problem is not here...
I think you should use the letterbox fit method to see the initial pixels you need to crop/pad first, then apply your resize factors after.

Can I find your sample file somewhere?
I will do my tests using it when available.

Thanks!
ckhouston
VSO Fanatic
Posts: 4590
Joined: Wed Aug 08, 2007 4:12 am

Re: Feature Request: Add Option "Keep Aspect Ratio"

Post by ckhouston »

The file has a DAR=2.25 and PAR=1.0. It is one I made from a still image several years ago, along with several other similar ones at different aspect ratios, for checking ConvertX problems. It does have 4 pixel tall black bars top and bottom and the rectangle was supposed to be square but came out with an aspect slightly less than the intended 1.0, I don't remember why but could probably make a better one now.

I will upload a shortened version when I can and notify you by email.

An image using the Letterbox option is attached. It shows 50 pixel bars added top and bottom to make it 16:9. My calculations agree with that as well as those shown above for the Pan-Scan method. But I disagree with the Remove black bars option which does change the aspect of the rectangle as shown by the images in the post above. To be more exact, I calculate cropping 84 pixels from the sides if 5 pixels are cropped from top and bottom of the Pan-Scan result. If only 4 pixels are cropped from top and bottom of the Pan-Scan result, as it should be, then 83 pixels should be cropped from the sides.
Attachments
Letterbox Fit method.jpg
Suse18
Posts: 6
Joined: Mon Oct 06, 2014 10:07 am

Re: Feature Request: Add Option "Keep Aspect Ratio"

Post by Suse18 »

cedric wrote:Feature request added in last beta version (1.5.0.10)...
Super fast, thank you!
But unfortunately when fixed output is chosen (DVD 16:9 PAL) the revised "Remove Black Bars" function still shows an incorrect stretched video result. I think there may be an error in your equations as the top bottom values show -75 while the left/right values show only -85 which is not enough for a correct AR. Should be around -133 according to ckhouston's equation from previous post: CHP = (SHP/SVP) x CVP which looks more like the original.
Below include 2 screenshots, first Original untouched than after Remove BB.
Please check and advise. Thanks again.

Regards,
Attachments
Original Untouched Letterbox
Original Untouched Letterbox
Still Stretched after "Remove Black Bars"
Still Stretched after "Remove Black Bars"
ckhouston
VSO Fanatic
Posts: 4590
Joined: Wed Aug 08, 2007 4:12 am

Re: Feature Request: Add Option "Keep Aspect Ratio"

Post by ckhouston »

Thanks for the new results Suse18.
ckhouston wrote:I will upload a shortened version when I can and notify you by email.
I did upload a shortened version with the bitrate also reduced (Shortened 2.25 AR.mp4) to save time with my slow dial-up connection, but none of the Fit methods in Video Converter have any effect with it for some reason, maybe you can find out why. I will upload the original file tonight if you really need it but you can easily make a similar file with a still image containing a rectangle.

Note that while Suse18's file is stretched too much vertically with the Remove black bars option mine is stretched too much horizontally so something is wrong.
ckhouston
VSO Fanatic
Posts: 4590
Joined: Wed Aug 08, 2007 4:12 am

Re: Feature Request: Add Option "Keep Aspect Ratio"

Post by ckhouston »

cedric,

The Shortened 2.25 AR.mp4 I uploaded to your FTP site is OK to use, I was mistaken when I wrote it wasn't in a post above.
ckhouston
VSO Fanatic
Posts: 4590
Joined: Wed Aug 08, 2007 4:12 am

Re: Feature Request: Add Option "Keep Aspect Ratio"

Post by ckhouston »

Project.jpg
Here is more evidence that my equations for Crop All Edges in http://forums.vso-software.fr/calculati ... t9319.html are good.

The image above shows a project with four files to be converted to 16:9 NTSC. The first file is the 2.25 AR.mp4 already discussed. The next two are similar in that they also contain the rectangle but have different aspect ratios. All of the first three files have a PAR of 1.0. The last file is a DVD structure of the first file (2.25 AR.mp4) converted to DVD5 NTSC at 16:9 using the Letterbox resize option, with a non-square PAR of course.

The four images below show more or less maximum cropping of all edges of the different files which does not eliminate the rectangle -- all cropping calculated with my equations.
Attachments
2.25 AR.mp4
2.25 AR.mp4
1.8 AR.mp4
1.8 AR.mp4
1.5 AR.mp4
1.5 AR.mp4
2.25 AR.mp4 converted to 16 to 9 NTSC DVD
2.25 AR.mp4 converted to 16 to 9 NTSC DVD
User avatar
cedric
VSO Team Member
Posts: 1374
Joined: Fri May 02, 2008 9:31 am
Location: Toulouse-FRANCE

Re: Feature Request: Add Option "Keep Aspect Ratio"

Post by cedric »

Yes i used your equations in last beta version... (really usefull post about pad/crop)
But i have a last problem when removing black bars from 16/9 input to 4/3 format.
I hadn't the time to investigate more, a lot of other tasks needed to be closed before week end.

Thank you!
ckhouston
VSO Fanatic
Posts: 4590
Joined: Wed Aug 08, 2007 4:12 am

Re: Feature Request: Add Option "Keep Aspect Ratio"

Post by ckhouston »

Thanks cedric. Those equations are versatile and have been checked for accuracy with many test files.

The Remove black bars option does work now in 1.5.0.11 for all previous my test cases. I even tried a new one with padding on all edges and it removed all it should, leaving only what was needed for Letterbox padding. So Suse18's problem should be fixed.

It doesn't work right when output is set to 4:3 as you mentioned, but the equations are still good for that case so there must be a problem in values used, hope it will be easy to find.

Maybe I should caution that SAR is the DAR of the source in those equations, not the storage aspect ratio that SAR is commonly used to designate.
Post Reply