All Products
Search
Document Center

:The video image has a gap with black borders

Last Updated:Jun 16, 2026

Black borders or gaps appear around the video when the player aspect ratio does not match the video aspect ratio.

Problem description

Black borders appear around the video image during playback, as shown in the following figure.

Possible cause

The aspect ratio of the player does not match the aspect ratio of the video.

Solution

  1. View the width and height of the video image, and the vedioWidth and vedioHeight parameters of the player.
    Note

    Note: you can use ffplay or related video analysis tools to view the width and height parameters. If you use apsaravideo player, you can view the width and length set when initializing the player.

  2. Adjusts the ratio of vedioWidth/vedioHeight to be the same as the width/height ratio.
    Note

    Note: note the following points when adjusting the aspect ratio of the player and the aspect ratio of the video:

    • If you are using apsaravideo player, adjust the values of the attributes and methods parameters. For more information, see vediowdth/vedioheight.
    • If you are using a live stream, you can see custom encoding to transcode the video by height.
    • If you are using on-demand streams, you can transcode the video by transcode. For more information, see transcode.

  3. After the aspect ratio is adjusted, play the video image and ensure that the player does not have margins.

Application scope

  • ApsaraVideo Live