- 函数注释
/**
* Guess the sample aspect ratio of a frame, based on both the stream and the
* frame aspect ratio. (基于流和frame的aspect ratio)
*
* Since the frame aspect ratio is set by the codec but the stream aspect ratio
* is set by the demuxer, these two may not be equal.
*
This function tries to
* return the value that you should use if you would like to display the frame.
*
* Basic logic is to use the stream aspect ratio if it is set to something sane
* otherwise use the frame aspect ratio. This way a container setting, which is
* usually easy to modify can override the coded value in the frames.
*
* @param format the format context which the stream is part of
* @param stream the stream which the frame is part of
* @param frame the frame with the aspect ratio to be determined
* @return the guessed (valid) sample_aspect_ratio, 0/1 if no idea
*/
AVRational av_guess_sample_aspect_ratio(AVFormatContext *format, AVStream *stream, AVFrame *frame);
个人理解
- frame aspect ratio 是编码器设置的,stream aspect ratio :是解码器设置的,它俩有可能不一样,毕竟,使用sws_scale 可以对画面 重采样
- 基本逻辑是:
- 先用 the stream aspect ratio,
- 若stream没有,就用:the frame aspect ratio.
说明:
- 基于流与视频帧的宽高比,猜测视频帧的屏幕宽高比。
- 流与视频帧的宽高比存在不同的情况,这个函数返回一个值,让你用于显示视频帧。
- 默认原则:先用stream中的宽高比,再选择frame的。
- 若没结果,则返回值为0/1。
重点
- 猜测视频帧的屏幕宽高比,显示视频帧
Note
- 用于显示视频之前。