<div dir="ltr"><div><div>I just noticed one more thing:<br><br></div>using:<br><br><div>AVStream *st = pFormatCtx->streams[your_video_index];</div>
<div>double frame_rate = st->r_frame_rate.num /
(double)st->r_frame_rate.den;<br><br></div><div>gives me correct values for 3gp files. When I tried this code on an MP4 file, I got about 49.9 value, which was incorrect (actual was 25); looking at other values, I tried following:<br>
<br>AVStream *st = pFormatCtx->streams[your_video_index ];<br>double frame_rate = st->avg_frame_rate.num / (double)st->avg_frame_rate.den;<br><br></div>It worked fine for MP4: {num=25 den=1 }, and for 3gp, I get: {num=64350000 den=2139391 } (30.078 FPS), which is also correct.<br>
<br></div>So I assume this might be better structure to refer to, until it breaks again on another video...?<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, May 22, 2013 at 8:48 AM, Taha Ansari <span dir="ltr"><<a href="mailto:mtaha.ansari@gmail.com" target="_blank">mtaha.ansari@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi <span name="Guohui Huang">Guohui Huan!<br><br></span></div><span name="Guohui Huang">Many thanks for your guidance, I have got it working now!<br>
<br>Thanks once again...<br></span> </div>
<div class="gmail_extra"><br><br><div class="gmail_quote"><div><div class="h5">On Wed, May 22, 2013 at 5:58 AM, Guohui Huang <span dir="ltr"><<a href="mailto:huanggh0108@sina.com" target="_blank">huanggh0108@sina.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><u></u>
<div 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" face="宋体" size="3">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" face="Verdana">2013-05-22</font></div>
<div align="left"><font face="Verdana">
<hr style="WIDTH:122px;min-height:2px" align="left" size="2"><span><font color="#888888">
</font></span></font></div><span><font color="#888888">
<div align="left"><font color="#c0c0c0" face="Verdana"><span>Guohui Huang</span></font></div>
<div><font face="Verdana">
<hr>
</font></div>
<div><font face="Verdana"><strong>发件人:</strong>Taha Ansari
<<a href="mailto:mtaha.ansari@gmail.com" target="_blank">mtaha.ansari@gmail.com</a>></font></div>
<div><font face="Verdana"><strong>发送时间:</strong><a href="tel:2013-05-21%C2%A023" value="+12013052123" target="_blank">2013-05-21 23</a>:04</font></div>
<div><font face="Verdana"><strong>主题:</strong>[Libav-user] Reading correct
frame rate (fps) of input video</font></div>
<div><font face="Verdana"><strong>收件人:</strong>"This list is about using
libavcodec, libavformat, libavutil, libavdevice and
libavfilter."<<a href="mailto:libav-user@ffmpeg.org" target="_blank">libav-user@ffmpeg.org</a>></font></div>
<div><font face="Verdana"><strong>抄送:</strong></font></div></font></span><div><div>
<div><font face="Verdana"></font> </div>
<div><font 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></div></div></div><br></div></div>_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" target="_blank">http://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>