<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<STYLE type=text/css> <!--@import url(scrollbar.css); --></STYLE>

<META content="text/html; charset=utf-8" http-equiv=Content-Type>
<STYLE>                   body{FONT-SIZE:12pt; FONT-FAMILY:宋体,serif;}         </STYLE>

<META name=GENERATOR content="MSHTML 9.00.8112.16476"><BASE 
target=_blank></HEAD>
<BODY 
style="LINE-HEIGHT: 1.3; BORDER-RIGHT-WIDTH: 0px; MARGIN: 12px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" 
marginheight="0" marginwidth="0">
<DIV><FONT color=#000000 size=3 face=宋体>You can get frame rate 
as follow:</FONT></DIV>
<DIV>AVStream *st = pFormatCtx->streams[your_video_index];</DIV>
<DIV>double frame_rate = st->r_frame_rate.num / 
(double)st->r_frame_rate.den;</DIV>
<DIV> </DIV>
<DIV align=left><FONT color=#c0c0c0 size=2 face=Verdana>2013-05-22</FONT></DIV>
<DIV align=left><FONT size=2 face=Verdana>
<HR style="WIDTH: 122px; HEIGHT: 2px" id=SignNameHR align=left SIZE=2>
</FONT></DIV>
<DIV align=left><FONT color=#c0c0c0 size=2 face=Verdana><SPAN 
id=_FlashSignName>Guohui Huang</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Verdana>
<HR>
</FONT></DIV>
<DIV><FONT size=2 face=Verdana><STRONG>发件人:</STRONG>Taha Ansari 
<mtaha.ansari@gmail.com></FONT></DIV>
<DIV><FONT size=2 
face=Verdana><STRONG>发送时间:</STRONG>2013-05-21 23:04</FONT></DIV>
<DIV><FONT size=2 face=Verdana><STRONG>主题:</STRONG>[Libav-user] Reading correct 
frame rate (fps) of input video</FONT></DIV>
<DIV><FONT size=2 face=Verdana><STRONG>收件人:</STRONG>"This list is about using 
libavcodec, libavformat, libavutil, libavdevice and 
libavfilter."<libav-user@ffmpeg.org></FONT></DIV>
<DIV><FONT size=2 face=Verdana><STRONG>抄送:</STRONG></FONT></DIV>
<DIV><FONT size=2 face=Verdana></FONT> </DIV>
<DIV><FONT size=2 face=Verdana>
<DIV dir=ltr>Hi!<BR><BR>I am trying to read exact values for frame rate (fps) 
from any input video file. I have been trying to debug different structures like 
AVFormatCtx, etc. but cannot seem to figure it out. For a test case, here is the 
code I have managed (just the source snippet, include files etc. are all 
understandable):<BR><BR>//---------------------------------------------------------------------------------------------------------------------------------------------------<BR>  
  // ++ test code begins ++//<BR>    av_register_all();<BR>  
  avcodec_register_all();<BR>    
avformat_network_init();<BR>    avdevice_register_all();<BR>  
  AVFormatContext *pFormatCtx = NULL;<BR>    pFormatCtx = 
avformat_alloc_context();<BR>    string finalInputName = 
"test_input.3gp";<BR>    avformat_open_input(&pFormatCtx, 
finalInputName.c_str(), NULL, NULL);<BR>    if ( pFormatCtx == NULL 
           ||<BR>        
pFormatCtx->iformat == NULL    )<BR>    {<BR>  
      return -1;<BR>    }<BR>    // Retrieve 
stream information<BR>    if(avformat_find_stream_info(pFormatCtx, 
NULL)<0)<BR>        return -1; // Couldn't find stream 
information<BR><BR>    // Dump information about file onto standard 
error<BR>    av_dump_format(pFormatCtx, 0, finalInputName.c_str(), 
0);<BR>    // -- test code ends 
--//<BR>//---------------------------------------------------------------------------------------------------------------------------------------------------<BR><BR>The 
output it gives me is (in debug 
console):<BR><BR>//---------------------------------------------------------------------------------------------------------------------------------------------------<BR>Input 
#0, mov,mp4,m4a,3gp,3g2,mj2, from 'test_input.3gp':<BR>  
Metadata:<BR>    major_brand     : 3gp4<BR>    
minor_version   : 0<BR>    compatible_brands: isom3gp4<BR>  
  creation_time   : 2013-05-20 11:54:39<BR>  Duration: 
00:00:23.77, start: 0.000000, bitrate: 5882 kb/s<BR>    Stream 
#0:0(eng): Video: mpeg4 (Advanced Simple Profile) (mp4v / 0x7634706D)<BR>, 
yuv420p, 640x480 [SAR 1:1 DAR 4:3], 5752 kb/s, 30.08 fps, 30.08 tbr, 90k 
tbn,<BR>300 tbc<BR>    Metadata:<BR>      creation_time 
  : 2013-05-20 11:54:39<BR>      handler_name    : 
VideoHandle<BR>    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 
16000 Hz, stereo, s16, 127<BR> kb/s<BR>    Metadata:<BR>  
    creation_time   : 2013-05-20 11:54:39<BR>      
handler_name    : 
SoundHandle<BR>//---------------------------------------------------------------------------------------------------------------------------------------------------<BR><BR>Like 
in above example, I can read that video is recorded at 30.08 fps, question is: 
it is apparently very simple for FFmpeg to figure this out, but how can I use 
this information from my own program? I was trying to follow code from FFmpeg 
source file (utils.c): [void av_dump_format(AVFormatContext *ic,  int 
index, const char *url, int is_output)], but was easily lost there.<BR><BR>Can 
anyone kindly guide me how to intercept this problem?<BR><BR>Thanks in advance 
for your time...</DIV></FONT></DIV></BODY></HTML>