When you encode normal video (4:3 aspect ration) to widescreen (16:9) video, or in reverse widescreen to normal video, video is stretch out and in result output distorted or bad in view and quality.
In order to avoid video stretching out and keep aspect ratio of video persistent, you can use technique called pillars. This is the "pure" method as it does not distort or lose any part of the original video or image. In this technique you will calculate space and add padding accordingly on proper direction to keep the aspect ratio of video consistent.
Logic to calculate padding size and direction.
1:
Widescreen (16:9) to Normal (4:3) video conversion:
Example:
i: Calculate width and height of source video (16:9): e.g
800x450 = 1.7777.
ii: Width and height of normal video that you want to publish e.g
320x240 = 1.333.
iii: Actual widescreen height of video based on output width : 320/1.77777 =
180.
iv: Calculate the difference between normal height and widescreen height = 240 - 180 =
60.
v: Divide 60 in two pieces will get the padding size for each side of video 60/2 =
30.
vi: In case of widescreen to normal conversion, difference comes in height so you will add padding on top and bottom of video.
So parameters for widescreen video (800x450) to normal video (320x240) conversion without stretching is
- Width: 320px
- Height: 180px
- Padding Top: 30px
- Padding Bottom: 30px
The result video size will be 320x240 or (4:3 aspect ratio) video.
You can achieve same settings through ASP.NET Media Handler Pro as
_mhandler.Width = 320;
_mhandler.Height = 180;
_mhandler.PadTop = 30;
_mhandler.PadBottom = 30;
1:
Normal (4:3) to Widescreen (16:9) video conversion:
Example
i: Same as above first get width and height of source video (4:3). e.g
800x600 = 1.3333.
ii: Width and height of output widescreen video. e.g
320x180 = 1.7777.
iii: Actual normal width of video based on widescreen height =
180x1.333 = 240
iv: Calculate the different between normal and widescreen widths = 320-240 = 60
v: Divide 60 in two pieces will get the padding size for each side of video 60/2 =
30.
vi: In case of normal to widescreen conversion, difference comes in widths so you will add padding on left and right of video.
So parameters for normal video (800x600) to widescreen video (320x160) conversion without stretching is
- Width: 240px
- Height: 180px
- Padding Left: 30px
- Padding Right: 30px
You can achieve same settings through ASP.NET Media Handler Pro as
_mhandler.Width = 320;
_mhandler.Height = 180;
_mhandler.PadLeft= 30;
_mhandler.PadRight= 30;
Checking video aspect ration:
Just divide width/height you will get aspect ratio of video. If you receive value like 1.333 it means video is normal video. If you receive value like 1.777 it means its widescreen video.
Note: In order to achieve conversion without stretching you must know
- Source video type whether its widescreen or normal video.
- In case of widescreen to normal video conversion, padding to be put on top and bottom of video based on logic describe above.
- In case of normal to widescreen video conversion, padding to be put on left and right of video based on logic as discussed above.
ASP.NET Media Handler Pro Documentation:
http://www.mediasoftpro.com/mediahandlerpro-v4-documentation.html
We appreciate feedback and comments.