[Libav-user] AVCodecContext: width/height info changes after avcodec_open()?

Martin Lambers marlam at marlam.de
Mon Oct 3 20:18:59 CEST 2011

Hi all,

I have a problem getting the correct width/height with a few video files.

After avformat_open_input(), the AVCodecContext entries for the video
stream report the following:

width/height: 1920x1080
coded_width/coded_height: 1920x1088

The difference of 8 pixels in height is presumably used to get a
multiple of 16.

But after calling avcodec_open() for that AVCodecContext, both value
pairs report the same:

width/height: 1920x1088
coded_width/coded_height: 1920x1088

Using these width/height values results in additional 8 gray pixel lines
at the bottom of each displayed frame. This also happens with FFplay
(from 0.8.5).

As a workaround, I now save the initial width/height information and use
that if it differs from the values after avcodec_open(). But is that
correct? Will this break in the future?

FFplay does not seem to use coded_width/coded_height at all. Does this
mean a video player program should always only use width/height? What
should be done when the two differ?


More information about the Libav-user mailing list