Add MediaFileInfo::overallAverageBitrate()

This commit is contained in:
Martchus 2019-03-10 16:31:47 +01:00
parent bd7d5b00d7
commit 0452b42bfc
3 changed files with 21 additions and 2 deletions

View File

@ -170,7 +170,7 @@ set(META_APP_AUTHOR "Martchus")
set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
set(META_APP_DESCRIPTION "C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags")
set(META_VERSION_MAJOR 8)
set(META_VERSION_MINOR 2)
set(META_VERSION_MINOR 3)
set(META_VERSION_PATCH 0)
set(META_PUBLIC_SHARED_LIB_DEPENDS c++utilities)
set(META_PUBLIC_STATIC_LIB_DEPENDS c++utilities_static)

View File

@ -853,7 +853,7 @@ bool MediaFileInfo::hasTracksOfType(MediaType type) const
}
/*!
* \brief Returns the overall duration of the file is known; otherwise
* \brief Returns the overall duration of the file if known; otherwise
* returns a TimeSpan with zero ticks.
*
* parseTracks() needs to be called before. Otherwise this
@ -871,6 +871,24 @@ ChronoUtilities::TimeSpan MediaFileInfo::duration() const
return TimeSpan();
}
/*!
* \brief Returns the overall average bitrate in kbit/s of the file if known; otherwise
* returns 0.0.
*
* parseTracks() needs to be called before. Otherwise this
* method always returns false.
*
* \sa parseTracks()
*/
double MediaFileInfo::overallAverageBitrate() const
{
const auto duration = this->duration();
if (duration.isNull()) {
return 0.0;
}
return 0.0078125 * size() / duration.totalSeconds();
}
/*!
* \brief Determines the available languages for specified media type (by default MediaType::Audio).
*

View File

@ -86,6 +86,7 @@ public:
std::vector<AbstractTrack *> tracks() const;
bool hasTracksOfType(TagParser::MediaType type) const;
ChronoUtilities::TimeSpan duration() const;
double overallAverageBitrate() const;
std::unordered_set<std::string> availableLanguages(TagParser::MediaType type = TagParser::MediaType::Audio) const;
std::string technicalSummary() const;
bool areTracksSupported() const;