The representation form of ffmpeg score
Before providing a possible solution to the time-consuming problem of avformat_find_stream_info, learn some basic ffmpeg knowledge points
Look at the code first.
PFormatContext- > streams [video _ index]-> time_base.den = 1200000
PFormatContext- > streams [video _ index]-> time_base.num = 1
/ / avg_frame_rate gets the frame rate
PFormatContext- > streams [video _ index]-> avg_frame_rate.den = 1
PFormatContext- > streams [video _ index]-> avg_frame_rate.num = 25
PFormatContext- > streams [video _ index]-> r_frame_rate.den = 25
PFormatContext- > streams [video _ index]-> r_frame_rate.num = 1
Notice that each structure has a member variable of den and num
By looking at the declaration, we can see that the above structure is actually such a type.
/ * *
* Rational number (pair of numerator and denominator).
, /
Typedef struct AVRational
{
Int num; / < Numerator
Molecule
Int den; / < Denominator denominator
} AVRational
Since the expression of the fraction is not convenient to calculate, one of the above structures is provided to preserve the numerator and denominator, etc.
Division is performed only when calculation is needed. Ffmpeg provides the following templates for division.
/ * *
* Convert rational to double.
* @ param a rational to convert
* @ return (double) a
, /
Static inline double av_q2d (AVRational a)
{
Return a.num / (double) a.den
}
Referenc
Http://www.jianshu.com/p/66b13b2b2979