When you specify the encoded video size to be 320×0, the resulting width is calculated based on the source aspect ratio. You will need to know what the exact frame size of your resulting video in order to enter the parameters you wish to keep.
First, you can find out the source media aspect ratio. Just send a GetMediaInfo API request, and locate property. If it is not present, just calculate the ratio from the frame size ( property) dividing width by height. Let’s now calculate result frame height. Divide the resulting width by the obtained ratio, round it to nearest integer, and then, if it is not even, add 1.
For example if source ratio is 1.333 (4:3).
320/1.333 = 240.06 In this case, the height will be 240.
For the source ratio 1.777 (16:9):
320/1.777 = 180.07. Therefore, the height will be 180.