Skip to content

Commit 46158b4

Browse files
author
Clement Champetier
committed
VideoProperties: fix getFps
* Use average framerate that has come from the AVStream. * Clean doc.
1 parent 6797dea commit 46158b4

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

src/AvTranscoder/mediaProperty/VideoProperties.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -516,17 +516,7 @@ int VideoProperties::getLevel() const
516516

517517
float VideoProperties::getFps() const
518518
{
519-
const Rational timeBase = getTimeBase();
520-
const float fps = timeBase.den / (double) timeBase.num;
521-
if( std::isinf( fps ) )
522-
{
523-
std::ostringstream os;
524-
os << "unable to retrieve a correct fps (found value: ";
525-
os << fps;
526-
os << ")";
527-
throw std::runtime_error( os.str() );
528-
}
529-
return fps;
519+
return av_q2d( _formatContext->streams[_streamIndex]->avg_frame_rate );
530520
}
531521

532522
bool VideoProperties::hasBFrames() const

src/AvTranscoder/mediaProperty/VideoProperties.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ class AvExport VideoProperties : public StreamProperties
5656
int getLevel() const;
5757

5858
/**
59-
* @brief Corresponds to the compute of the 'tbn' by ffmpeg.
60-
* tbn = the time base in AVStream that has come from the container
59+
* @brief Corresponds to the 'fps' returned by ffprobe.
60+
* fps = the average framerate that has come from the AVStream
61+
* tbn = the time base in AVStream that has come from the AVStream
6162
* tbc = the time base in AVCodecContext for the codec used for a particular stream
6263
* tbr = tbr is guessed from the video stream and is the value users want to see when they look for the video frame rate
63-
* @return
6464
*/
6565
float getFps() const;
6666

0 commit comments

Comments
 (0)