Hi Guohui Huan! Many thanks for your guidance, I have got it working now!
Thanks once again... On Wed, May 22, 2013 at 5:58 AM, Guohui Huang <[email protected]> wrote: > ** > You can get frame rate as follow: > AVStream *st = pFormatCtx->streams[your_video_index]; > double frame_rate = st->r_frame_rate.num / (double)st->r_frame_rate.den; > > 2013-05-22 > ------------------------------ > Guohui Huang > ------------------------------ > *发件人:*Taha Ansari <[email protected]> > *发送时间:*2013-05-21 23:04 > *主题:*[Libav-user] Reading correct frame rate (fps) of input video > *收件人:*"This list is about using libavcodec, libavformat, libavutil, > libavdevice and libavfilter."<[email protected]> > *抄送:* > > Hi! > > 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): > > > //--------------------------------------------------------------------------------------------------------------------------------------------------- > // ++ test code begins ++// > av_register_all(); > avcodec_register_all(); > avformat_network_init(); > avdevice_register_all(); > AVFormatContext *pFormatCtx = NULL; > pFormatCtx = avformat_alloc_context(); > string finalInputName = "test_input.3gp"; > avformat_open_input(&pFormatCtx, finalInputName.c_str(), NULL, NULL); > if ( pFormatCtx == NULL || > pFormatCtx->iformat == NULL ) > { > return -1; > } > // Retrieve stream information > if(avformat_find_stream_info(pFormatCtx, NULL)<0) > return -1; // Couldn't find stream information > > // Dump information about file onto standard error > av_dump_format(pFormatCtx, 0, finalInputName.c_str(), 0); > // -- test code ends --// > > //--------------------------------------------------------------------------------------------------------------------------------------------------- > > The output it gives me is (in debug console): > > > //--------------------------------------------------------------------------------------------------------------------------------------------------- > Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test_input.3gp': > Metadata: > major_brand : 3gp4 > minor_version : 0 > compatible_brands: isom3gp4 > creation_time : 2013-05-20 11:54:39 > Duration: 00:00:23.77, start: 0.000000, bitrate: 5882 kb/s > Stream #0:0(eng): Video: mpeg4 (Advanced Simple Profile) (mp4v / > 0x7634706D) > , yuv420p, 640x480 [SAR 1:1 DAR 4:3], 5752 kb/s, 30.08 fps, 30.08 tbr, 90k > tbn, > 300 tbc > Metadata: > creation_time : 2013-05-20 11:54:39 > handler_name : VideoHandle > Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 16000 Hz, stereo, > s16, 127 > kb/s > Metadata: > creation_time : 2013-05-20 11:54:39 > handler_name : SoundHandle > > //--------------------------------------------------------------------------------------------------------------------------------------------------- > > 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. > > Can anyone kindly guide me how to intercept this problem? > > Thanks in advance for your time... > > _______________________________________________ > Libav-user mailing list > [email protected] > http://ffmpeg.org/mailman/listinfo/libav-user > >
_______________________________________________ Libav-user mailing list [email protected] http://ffmpeg.org/mailman/listinfo/libav-user
