Community
cancel
Showing results for 
Search instead for 
Did you mean: 
steveipp
Beginner
49 Views

preserving aspect ratio and adding border bands when resizing video

Hi,

Do the UMC video codec APIs provide a way to preserve aspect ratios and add border bands when transcoding video between picture sizes that have different aspect ratios?

For example, I'd like to transcode H.263 4CIF (704x576), which as aspect ratio of 1.222... to picture sizes that are shorter but have a wider aspect ratio such as 525 SD (720 x 480, aspect ratio 1.5) or 768 x 448 (aspect ratio 1.714).

The default resizing simply scales the picture to fit the target size, thereby resulting in an image that's stretched a bit wide.

How would I go about resizing such that the original image's aspect ratio is preserved and black border bands are added to the left and right of the image to pad it out to the target width?

Any suggestionswouldbereallyappreciated.

I searched the UMC manual and the forum before posting this question. My apologies if this indeed has been discussed.

Thanks,

Steve

0 Kudos
3 Replies
Chao_Y_Intel
Employee
49 Views

Hello Steve,

I think it needs a bit change to the code:

1) First call the resize function according to the aspect ratios

2) then, use ippiCopyConstBorder_ function to fill in the black value in the left and right of the image

Thanks,

Chao

Naveen_G_Intel
Employee
49 Views

Hi Steve,

As I know one function is there in UMC, SetAspectRatio, this will set the pixel aspect ratio characteristics for the video frame.

Regards,

Naveen Gv

steveipp
Beginner
49 Views

Let's walk through the use case of decoding H.264 video, resizing it, adding border lines, and re-encoding it in H.264. The H264VideoDecoder provides decoded images in YUV420 planar format, and the H264VideoEncoder expects images in YUV420 planar format. Does this mean I need to call ippiYUV420ToRGB_ on the H264VideoDecoder's output to convert to pixel format, call ippiCopyConstBorder_ to add the border lines, then call ippiRGBToYUV420_ to convert back to planar format before invoking H264VideoEncoder? Or is there another way to accomplish this?

Thanks,
Steve
Reply