Skip to content

Commit 11c7173

Browse files
authored
Merge pull request #290 from cchampet/fix_VideoPropertiesGetFpsWithoutAverageFramerate
VideoProperties: fix getFps if the average framerate is not defined
2 parents 985a661 + f7ef5be commit 11c7173

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/AvTranscoder/properties/VideoProperties.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,12 @@ int VideoProperties::getLevel() const
432432

433433
float VideoProperties::getFps() const
434434
{
435-
return av_q2d(_formatContext->streams[_streamIndex]->avg_frame_rate);
435+
if(! _formatContext)
436+
throw std::runtime_error("unknown format context");
437+
438+
if(_formatContext->streams[_streamIndex]->avg_frame_rate.den)
439+
return av_q2d(_formatContext->streams[_streamIndex]->avg_frame_rate);
440+
return av_q2d(av_inv_q(getTimeBase()));
436441
}
437442

438443
float VideoProperties::getDuration() const

src/AvTranscoder/properties/VideoProperties.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class AvExport VideoProperties : public StreamProperties
6464

6565
/**
6666
* @brief Corresponds to the 'fps' returned by ffprobe.
67+
* @note If the average framerate is not defined in the format, return the tbn.
6768
* fps = the average framerate that has come from the AVStream
6869
* tbn = the time base in AVStream that has come from the AVStream
6970
* tbc = the time base in AVCodecContext for the codec used for a particular stream

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy