Skip to content

Commit 427b9b2

Browse files
author
Clement Champetier
committed
Video/AudioProperties: fix check of AVFormatContext when getTimeBase
Remove check of AVFormatContext when getDuration.
1 parent 44add38 commit 427b9b2

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

src/AvTranscoder/mediaProperty/AudioProperties.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ size_t AudioProperties::getTicksPerFrame() const
172172

173173
Rational AudioProperties::getTimeBase() const
174174
{
175-
if( ! _codecContext )
176-
throw std::runtime_error( "unknown codec context" );
175+
if( ! _formatContext )
176+
throw std::runtime_error( "unknown format context" );
177177

178178
Rational timeBase = {
179179
_formatContext->streams[_streamId]->time_base.num,
@@ -193,9 +193,6 @@ double AudioProperties::getFps() const
193193

194194
double AudioProperties::getDuration() const
195195
{
196-
if( ! _formatContext )
197-
throw std::runtime_error( "unknown format context" );
198-
199196
Rational timeBase = getTimeBase();
200197
double duration = ( timeBase.num / (double) timeBase.den ) * _formatContext->streams[_streamId]->duration;
201198
return duration;

src/AvTranscoder/mediaProperty/VideoProperties.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,8 @@ std::string VideoProperties::getStartTimecodeString() const
337337

338338
Rational VideoProperties::getTimeBase() const
339339
{
340-
if( ! _codecContext )
341-
throw std::runtime_error( "unknown codec context" );
340+
if( ! _formatContext )
341+
throw std::runtime_error( "unknown format context" );
342342

343343
Rational timeBase = {
344344
_formatContext->streams[_streamId]->time_base.num,
@@ -479,9 +479,6 @@ double VideoProperties::getFps() const
479479

480480
double VideoProperties::getDuration() const
481481
{
482-
if( ! _formatContext )
483-
throw std::runtime_error( "unknown format context" );
484-
485482
Rational timeBase = getTimeBase();
486483
double duration = ( timeBase.num / (double) timeBase.den ) * _formatContext->streams[_streamId]->duration;
487484
return duration;

0 commit comments

Comments
 (0)