Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenCV Reporting TBR instead of FPS when using capture.get(CV_CAP_PROP_FPS)
    text
    copied!<p>I have several videos that I am trying to process using OpenCV and Qt 4.7.4 on Mac OS 10.6.8 (Snow Leopard). If I create a <code>cv::VideoCapture</code> object and then query for the frame rate related to such video, what I get back is the TBR and not FPS. </p> <p>For instance if use <code>ffprobe Video1.mp4</code> what I get is:</p> <pre><code>&gt;&gt; ffprobe Video1.mp4 ffprobe version 0.7.8, Copyright (c) 2007-2011 the FFmpeg developers built on Nov 24 2011 14:31:00 with gcc 4.2.1 (Apple Inc. build 5666) (dot 3) configuration: --prefix=/opt/local --enable-gpl --enable-postproc --enable-swscale -- enable-avfilter --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable- libdirac --enable-libschroedinger --enable-libopenjpeg --enable-libxvid --enable-libx264 --enable-libvpx --enable-libspeex --mandir=/opt/local/share/man --enable-shared -- enable-pthreads --cc=/usr/bin/gcc-4.2 --arch=x86_64 --enable-yasm libavutil 50. 43. 0 / 50. 43. 0 libavcodec 52.123. 0 / 52.123. 0 libavformat 52.111. 0 / 52.111. 0 libavdevice 52. 5. 0 / 52. 5. 0 libavfilter 1. 80. 0 / 1. 80. 0 libswscale 0. 14. 1 / 0. 14. 1 libpostproc 51. 2. 0 / 51. 2. 0 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Video1.mp4': Metadata: major_brand : isom minor_version : 0 compatible_brands: mp41avc1qt creation_time : 2012-01-09 23:09:43 encoder : vlc 1.1.3 stream output encoder-eng : vlc 1.1.3 stream output Duration: 00:10:10.22, start: 0.000000, bitrate: 800 kb/s Stream #0.0(eng): Video: h264 (Baseline), yuvj420p, 704x480 [PAR 10:11 DAR 4:3], 798 kb/s, 27.71 fps, 1001 tbr, 1001 tbn, 2002 tbc Metadata: creation_time : 2012-01-09 23:09:43 </code></pre> <p>Which correctly reports FPS = 27.71 and TBR = 1001. Nevertheless if I use the following OpenCV code to query for the FPS:</p> <pre><code>QString filename = QFileDialog::getOpenFileName(this, "Open Video", "Video Files (*.mp4, *.mpg)"); capture.release(); capture.open(filename.toAscii().data()); if (!capture.isOpened()){ qDebug() &lt;&lt;"Error when opening the video!"; return; } qDebug() &lt;&lt; "Frame Rate:" &lt;&lt; capture.get(CV_CAP_PROP_FPS); qDebug() &lt;&lt; "Num of Frames:" &lt;&lt; capture.get(CV_CAP_PROP_FRAME_COUNT); qDebug() &lt;&lt; "OpenCV Version" &lt;&lt; CV_VERSION; </code></pre> <p>The output I get is:</p> <pre><code>Frame Rate: 1001 Num of Frames: 610832 OpenCV Version 2.3.1 </code></pre> <p>Which reports the TBR instead of the FPS. This behavior is consistent when I try to open different videos. </p> <p>I checked OpenCV's <a href="http://code.opencv.org/projects/opencv/issues" rel="nofollow noreferrer">bug tracker</a> and I also found <a href="https://stackoverflow.com/questions/4352939/opencv-doesnt-report-accurate-frame-rate-count">this</a> stack overflow question to be a similar but not quite the same problem, so I am at a loss to what to do next. Any hint or idea is most welcome since I've tried lots of things and seem to be getting nowhere.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload