File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed
src/AvTranscoder/mediaProperty Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -14,23 +14,25 @@ namespace avtranscoder
14
14
AudioProperties::AudioProperties ( const AVFormatContext* formatContext, const size_t index )
15
15
: _formatContext( formatContext )
16
16
, _codecContext( formatContext->streams[index]->codec )
17
+ , _codec( NULL )
17
18
, _streamId( index )
18
- {}
19
+ {
20
+ if ( _formatContext && _codecContext )
21
+ _codec = avcodec_find_decoder ( _codecContext->codec_id );
22
+ }
19
23
20
24
std::string AudioProperties::getCodecName () const
21
25
{
22
- AVCodec* codec = avcodec_find_decoder ( _codecContext->codec_id );
23
- if ( codec != NULL )
24
- return std::string ( codec->name );
26
+ if ( _codec && _codec->name )
27
+ return std::string ( _codec->name );
25
28
else
26
29
return " unknown codec" ;
27
30
}
28
31
29
32
std::string AudioProperties::getCodecLongName () const
30
33
{
31
- AVCodec* codec = avcodec_find_decoder ( _codecContext->codec_id );
32
- if ( codec != NULL )
33
- return std::string ( codec->long_name );
34
+ if ( _codec && _codec->long_name )
35
+ return std::string ( _codec->long_name );
34
36
return " unknown codec" ;
35
37
}
36
38
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ class AvExport AudioProperties
43
43
private:
44
44
const AVFormatContext* _formatContext; // /< Has link (no ownership)
45
45
AVCodecContext* _codecContext; // /< Has link (no ownership)
46
+ AVCodec* _codec; // /< Has link (no ownership)
46
47
47
48
size_t _streamId;
48
49
MetadatasMap _metadatas;
You can’t perform that action at this time.
0 commit comments