2012-02-22 1 views
1

を使用するときにOpenCVのではなく、FPSのTBRを報告私は、Mac OS 10.6.8(Snow Leopardは)上のOpenCVとQt 4.7.4を使用して処理しようとしているいくつかのビデオを持っています。私はcv::VideoCaptureオブジェクトを作成し、ビデオに関連するフレームレートを問い合わせる場合は、私が戻って取得することはTBRはないFPSです。例えばcapture.get(CV_CAP_PROP_FPS)

私は何を得るの使用ffprobe Video1.mp4がある場合:

私はFPSを照会するには、以下のOpenCVのコードを使用している場合、正しくそれでもFPS = 27.71とTBR = 1001をレポート
>> 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 

QString filename = QFileDialog::getOpenFileName(this, 
             "Open Video", 
             "Video Files (*.mp4, *.mpg)"); 

capture.release(); 
capture.open(filename.toAscii().data()); 

if (!capture.isOpened()){ 
    qDebug() <<"Error when opening the video!"; 
    return; 
} 


qDebug() << "Frame Rate:" << capture.get(CV_CAP_PROP_FPS); 
qDebug() << "Num of Frames:" << capture.get(CV_CAP_PROP_FRAME_COUNT); 
qDebug() << "OpenCV Version" << CV_VERSION; 

私が手出力は次のようになります。代わりにTBRを報告

Frame Rate: 1001 
Num of Frames: 610832 
OpenCV Version 2.3.1 

FPSのこの動作は、異なるビデオを開くときに一貫しています。

私はOpenCVのbug trackerをチェックしましたが、thisというスタックオーバーフローの問題は、同様の問題だとは言えませんが、私は次に何をするのか迷っています。私はたくさんのことを試して、どこにもいないように見えるので、ヒントやアイデアは大歓迎です。

答えて

3

私はフレームレートが実際に何であるかについてのffmpeg's best guessであるため、彼らはTBRを報告することを選んだと想像。多くのコンテナでは、fpsフィールド(具体的にはAVStream.avg_frame_rate)は使用できないため、実際には使用できません。

TBR(ffmpegのの最良の推測):

struct AVStream { 
... 
/** 
* Real base framerate of the stream. 
* This is the lowest framerate with which all timestamps can be 
* represented accurately (it is the least common multiple of all 
* framerates in the stream). Note, this value is just a guess! 
* For example, if the time base is 1/90000 and all frames have either 
* approximately 3600 or 1800 timer ticks, then r_frame_rate will be 50/1. 
*/ 
AVRational r_frame_rate; 

TBC(コーデックタイムベース)

ここ

はTBR、TBC、およびTBNフィールド上ffmpeg源からのコメントです。

struct AVCodecContext { 
... 
/** 
* This is the fundamental unit of time (in seconds) in terms 
* of which frame timestamps are represented. For fixed-fps content, 
* time base should be 1/framerate and timestamp increments should be 1. 
* decoding: set by libavformat 
* encoding: set by libavformat in av_write_header 
*/ 
AVRational time_base; 

TBN(ストリーム(コntainer)タイムベース):

struct AVStream { 
... 
/** 
* This is the fundamental unit of time (in seconds) in terms 
* of which frame timestamps are represented. For fixed-fps content, 
* timebase should be 1/framerate and timestamp increments should be 
* identically 1. 
* - encoding: MUST be set by user. 
* - decoding: Set by libavcodec. 
*/ 
AVRational time_base; 

うまくいけば、TBRはなくFPSで報告された理由を説明します。それを決定することができないにもかかわらず、それを(...例えば、AVI、MP4、DivXの、XviDの、など)ffmpegは困難あなたのビデオストリームのタイムベース、およびコンテナの決定をしている表示されますフレームレートを提供し、そうffmpegディスプレイ分析を通じて。ビデオを正しくエンコードすることは可能ですか?動画はかなりの数であり、やや長いですので、

+0

ビデオを再エンコード、なんとかものの、面倒になります。それらはネットワークカメラから生成されます。しかし、あなたの答えは、なぜFPSの代わりにTBRを得るのか明確な説明を与えました。ありがとう! – Malife