<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Oct 31, 2016 at 10:07 PM, YIRAN LI <span dir="ltr"><<a href="mailto:mrfun.china@gmail.com" target="_blank">mrfun.china@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-family:georgia,serif">MediaInfo can show max/min frame rate for a variable frame rate video</div><div style="font-family:georgia,serif"><br></div><div style="font-family:georgia,serif"><img src="cid:ii_iuyur41r0_1581da254c9f949d" width="274" height="74"><br>​<br></div><div style="font-family:georgia,serif">Can I get these info from AVCodec, AVCodecContext or AVFormatContext?</div></div></blockquote><div><br></div><div>From what I can see in the source, MediaInfo can only calculate min/max frame rate in two situations:</div><div><br></div><div>For MPEG4 containers, in Source/MediaInfo/Multiple/<wbr>File_Mpeg4.cpp, in very specific situations:</div><div><br></div><div><div><font face="monospace, monospace">    if (Temp->second.stts_Max)</font></div><div><font face="monospace, monospace">        Fill(Stream_Video, StreamPos_Last, Video_FrameRate_Minimum, ((float)Temp->second.mdhd_<wbr>TimeScale)/Temp->second.stts_<wbr>Max, 3, true);</font></div><div><font face="monospace, monospace">    if (Temp->second.stts_Min)</font></div><div><font face="monospace, monospace">        Fill(Stream_Video, StreamPos_Last, Video_FrameRate_Maximum, ((float)Temp->second.mdhd_<wbr>TimeScale)/Temp->second.stts_<wbr>Min, 3, true);</font></div></div><div><br></div><div>For AVI containers, in Source/MediaInfo/Multiple/<wbr>File_Riff.cpp, it appears to just make something up; logic that is probably justified but beyond my personal understanding:</div><div><br></div><div><div><font face="monospace, monospace">    float32 FrameRateF=FrameRate.To_<wbr>float32();</font></div><div><font face="monospace, monospace">    Fill(Stream_Video, StreamPos_Last, Video_FrameRate_Minimum, FrameRateF/5, 3, true);</font></div><div><font face="monospace, monospace">    Fill(Stream_Video, StreamPos_Last, Video_FrameRate_Maximum, FrameRateF/4, 3, true);</font></div></div><div><br></div><div>In the MPEG4 case, stts_Min and stts_Max are filled by scanning the entire file in File_Mpeg4_Elements.cpp.</div><div><br></div><div>In the AVI case, FrameRate is filled in various places in File_Riff_Elements.cpp, I think by just reading a value from the file somewhere.</div><div><br></div><div>So you would have to do something similar. To accurately determine the value in all cases you'll have to demux the stream and examine all the PTS values. Other than that, there are no ffmpeg struct fields that give this information and no way for it to know without reading stream timestamps.</div><div><br></div><div>You can probably get away with just demuxing and taking a look at packet PTS values, rather than decoding fully, if you want to do as quick of an analysis as possible, although don't quote me on that, just test it: a lot of video decoding things are beyond my understanding. Some confirmation from somebody else here would be nice.</div><div><br></div><div>J </div></div></div></div>