Skip to content

Commit 75620c0

Browse files
author
Clement Champetier
committed
VideoProperties: fixed getDuration if cannot compute the bitrate
Avoid 'Arithmetic exception'.
1 parent 0fcd0cc commit 75620c0

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/AvTranscoder/properties/VideoProperties.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,12 @@ float VideoProperties::getDuration() const
473473
LOG_WARN("The duration of the stream '" << _streamIndex << "' of file '" << _formatContext->filename << "' is unknown.")
474474
if(_fileProperties->isRawFormat())
475475
{
476-
LOG_INFO("Get the file size to compute the duration.")
477-
return _fileProperties->getFileSize() / getBitRate() * 8;
476+
const size_t bitRate = getBitRate();
477+
if(bitRate)
478+
{
479+
LOG_INFO("Get the file size to compute the duration.")
480+
return _fileProperties->getFileSize() / bitRate * 8;
481+
}
478482
}
479483
return 0;
480484
}

src/AvTranscoder/properties/VideoProperties.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class AvExport VideoProperties : public StreamProperties
4040
Rational getSar() const; // sample/pixel aspect ratio
4141
Rational getDar() const; // display aspect ratio
4242

43-
size_t getBitRate() const; ///< in bits/s
43+
size_t getBitRate() const; ///< in bits/s, 0 if unknown
4444
size_t getMaxBitRate() const;
4545
size_t getMinBitRate() const;
4646
size_t getNbFrames() const; ///< 0 if unknown

0 commit comments

Comments
 (0)