Skip to content

Commit 81e811f

Browse files
committed
hotfix: store first AVCodecContext::timecode_frame_start
* fixing VideoProperties::getStartTimecode method return value
1 parent 6b4373c commit 81e811f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/AvTranscoder/mediaProperty/VideoProperties.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ VideoProperties::VideoProperties( const FormatContext& formatContext, const size
2222
, _pixelProperties()
2323
, _isInterlaced( false )
2424
, _isTopFieldFirst( false )
25+
, _firstGopTimeCode( -1 )
2526
, _gopStructure()
2627
{
2728
if( _formatContext )
@@ -39,7 +40,10 @@ VideoProperties::VideoProperties( const FormatContext& formatContext, const size
3940
_codec = avcodec_find_decoder( _codecContext->codec_id );
4041

4142
if( _codecContext )
43+
{
4244
_pixelProperties = PixelProperties( _codecContext->pix_fmt );
45+
_firstGopTimeCode = _codecContext->timecode_frame_start;
46+
}
4347

4448
if( level == eAnalyseLevelFirstGop )
4549
analyseGopStructure( progress );
@@ -310,7 +314,7 @@ int64_t VideoProperties::getStartTimecode() const
310314
{
311315
if( ! _codecContext )
312316
throw std::runtime_error( "unknown codec context" );
313-
return _codecContext->timecode_frame_start;
317+
return _firstGopTimeCode;
314318
}
315319

316320
std::string VideoProperties::getStartTimecodeString() const

src/AvTranscoder/mediaProperty/VideoProperties.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ class AvExport VideoProperties : public StreamProperties
110110
bool _isTopFieldFirst;
111111
std::vector< std::pair< char, bool > > _gopStructure;
112112
//@}
113+
114+
/**
115+
* @brief GOP timecode of the first frame
116+
* @note AVCodecContext stores the GOP timecode of the last decoded frame
117+
*/
118+
int64_t _firstGopTimeCode;
113119
};
114120

115121
}

0 commit comments

Comments
 (0)