File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed
src/AvTranscoder/mediaProperty Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -157,9 +157,14 @@ size_t AudioProperties::getBitRate() const
157
157
{
158
158
if ( ! _codecContext )
159
159
throw std::runtime_error ( " unknown codec context" );
160
- int bitsPerSample = av_get_bits_per_sample ( _codecContext->codec_id );
161
- size_t bitRate = bitsPerSample ? _codecContext->sample_rate * _codecContext->channels * bitsPerSample : _codecContext->bit_rate ;
162
- return bitRate;
160
+
161
+ // return bit rate of stream
162
+ if ( _codecContext->bit_rate )
163
+ return _codecContext->bit_rate ;
164
+
165
+ // else get computed bit rate from our computation (warning: way to compute bit rate of PCM audio data)
166
+ int bitsPerSample = av_get_bits_per_sample ( _codecContext->codec_id ); // 0 if unknown for the given codec
167
+ return _codecContext->sample_rate * _codecContext->channels * bitsPerSample;
163
168
}
164
169
165
170
size_t AudioProperties::getNbSamples () const
Original file line number Diff line number Diff line change @@ -28,8 +28,8 @@ class AvExport AudioProperties
28
28
size_t getCodecId () const ;
29
29
size_t getSampleRate () const ;
30
30
size_t getChannels () const ;
31
- size_t getBitRate () const ;
32
- size_t getNbSamples () const ;
31
+ size_t getBitRate () const ; // /< 0 if unknown
32
+ size_t getNbSamples () const ; // /< 0 if unknown
33
33
34
34
size_t getTicksPerFrame () const ;
35
35
Rational getTimeBase () const ;
You can’t perform that action at this time.
0 commit comments