[Libav-user] Getting the correct display resolution

Info || Non-Lethal Applications info at non-lethal-applications.com
Wed May 6 18:53:45 EEST 2020

I’ve been trying to find a reliably way to get the correct display resolution for a given file.

There’s AVVideoCodecContext->width/height, coded_width/coded_height and also sample_aspect_ratio.
There’s also AVStream->sample_aspect_ratio, display_aspect_ratio and AVFrame->sample_aspect_ratio.

Can anybody shed some light on this topic?
What’s the best way to find a video file’s source and display resolution (with source being the size of the actual buffer and display being the cropped, letterboxed etc. version to be presented to the user)?
Is there some kind of order in which they should be checked?

Thanks a lot in advance!

Best regards,


More information about the Libav-user mailing list