amazon-elastic-transcoderaws-media-convert

MediaConvert remove black bars


I'm trying to migrate from AWS ElasticTranscodder to MediaConvert. One thing that worked for ET is that output had maximum width and height, but for MC those values are fixed and you end up with blackbars if video does not exactly match aspect. Is it possible to crop the output to remove those black bars>


Solution

  • Thanks for your post. Yes you can remove the black bars in the MediaConvert output which normally appear when the input dimensions or aspect ratio are different from the intended output dimensions or aspect ratio.

    There are four parameters which can be tuned:

    [a] input dimension cropping (optional) - adjust this if you wish to use a sub-region of the original source picture. Useful when the original source has vertical bars on the sides, and you only want the video content from the center of the image.

    [b] Output dimensions (resolution & Aspect Ratio) -- if the Aspect Ratio ( Horiz. size ÷ Vertical size ) specified for output does not match the AR of the input (for example, converting a 16x9 asset to a 16x10 output), then pillar-box or letter-box bars are inserted by default in order to preserve the H/V proportions of the original content (meaning, the content is not "stretched".) Note: all dimensions must be multiples of 2.

    [c] Scaling Behavior -- default is to scale proportionally (see above); the alternative is "stretch to output" which stretches the output non-proportionally to the specified H+V output resolution. If the AR change is small, the stretching may not be noticeable. Further testing suggested.

    [d] Output position rectangle -- this setting defines how much of the output canvas should be covered with the transcoded content. It defaults to covering the entire output canvas as defined in step B. Specify other offsets or dimensions here to position or crop the transcoded output.

    Workflow tips:

    If you want the aspect ratio of the original content to be maintained with no black borders, you will need to calculate the original AR and use it to determine the new scaled-up dimensions. If this math is done correctly then there should be no black bars on the output.

    Some MediaConvert customers do this math using an AWS Lambda function which customizes the MediaConvert job settings before submitting the job. The Lambda function can be triggered automatically using S3 File events (i.e, new file arrival). The Lambda function can leverage media file utilities such as ffmpeg or mediainfo to determine the resolution and other metadata from the source file. The metadata can then be used to calculate settings for the MediaConvert job.