[object Object] Icon

Encoding
Learn how to create, start, manage and modify Encodings

[object Object] Icon

Player
Learn how to create, start, manage and modify Players

[object Object] Icon

Analytics
Learn how to create, start, manage and modify Analyticss

Docs Home
User shortcuts for search
Focus by pressing f
Hide results by pressing Esc
Navigate via   keys

Wed Oct 16 2019

How do I configure an codec configuration to maintain aspect ratio of the original video?

You can create an codec configuration, that will keep the aspect ratio of the original video by just omitting either the width or the height when you create it. Doing so, our service will maintain the aspect ratio of your input file, and calculate the omitted value based on that.

In the following an example for an encoding profile that will keep aspect ratio:

Open API SDK Java Example - Create an H264 Codec Configuration that maintains the aspect ratio:

1//Maintain the aspect ratio of the input file by providing "height" only
2H264VideoConfiguration config = new H264VideoConfiguration();
3config.setName("H264 - 1080p");
4config.setPresetConfiguration(PresetConfiguration.VOD_STANDARD);
5config.setBitrate(4800000L);
6config.setHeight(1080L);
7
8return bitmovinApi.encoding.configurations.video.h264.create(config);
9
10
11//Maintain the aspect ratio of the input file by providing "width" only
12H264VideoConfiguration config = new H264VideoConfiguration();
13config.setName("H264 - 1080p");
14config.setPresetConfiguration(PresetConfiguration.VOD_STANDARD);
15config.setBitrate(4800000L);
16config.setWidth(1920L);
17
18return bitmovinApi.encoding.configurations.video.h264.create(config);

This example is based on our Open API SDK for Java, which is available on Github. Please see our Open API SDK overview for all our supported programming languages, and our GH API SDK Example Repository for further examples.

Give us feedback