Skip to content

Commit 8a224d0

Browse files
author
Clement Champetier
committed
hotfix: set fps to 25 for AudioGenerator
1 parent b3b4a5b commit 8a224d0

File tree

3 files changed

+5
-15
lines changed

3 files changed

+5
-15
lines changed

src/AvTranscoder/codec/AudioCodec.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ AudioFrameDesc AudioCodec::getAudioFrameDesc() const
2525
{
2626
assert( _avCodecContext != NULL );
2727
AudioFrameDesc audioFrameDesc( _avCodecContext->sample_rate, _avCodecContext->channels, _avCodecContext->sample_fmt );
28-
double fps = 1.0 * _avCodecContext->time_base.den / ( _avCodecContext->time_base.num * _avCodecContext->ticks_per_frame );
29-
if( ! std::isinf( fps ) )
30-
audioFrameDesc.setFps( fps );
3128
return audioFrameDesc;
3229
}
3330

@@ -36,9 +33,6 @@ void AudioCodec::setAudioParameters( const AudioFrameDesc& audioFrameDesc )
3633
_avCodecContext->sample_rate = audioFrameDesc.getSampleRate();
3734
_avCodecContext->channels = audioFrameDesc.getChannels();
3835
_avCodecContext->sample_fmt = audioFrameDesc.getSampleFormat();
39-
_avCodecContext->time_base.num = 1;
40-
_avCodecContext->time_base.den = audioFrameDesc.getFps();
41-
_avCodecContext->ticks_per_frame = 1;
4236
}
4337

4438
}

src/AvTranscoder/decoder/AudioGenerator.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ AudioGenerator::~AudioGenerator()
2020
void AudioGenerator::setAudioFrameDesc( const AudioFrameDesc& frameDesc )
2121
{
2222
_frameDesc = frameDesc;
23+
_frameDesc.setFps( 25. );
2324
}
2425

2526
void AudioGenerator::setFrame( Frame& inputFrame )

src/AvTranscoder/frame/AudioFrame.hpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,18 @@ namespace avtranscoder
1717
class AvExport AudioFrameDesc
1818
{
1919
public:
20-
/**
21-
* @warning FPS value is set to 25 by default
22-
*/
2320
AudioFrameDesc( const size_t sampleRate = 0, const size_t channels = 0, const AVSampleFormat sampleFormat = AV_SAMPLE_FMT_NONE )
2421
: _sampleRate( sampleRate )
2522
, _channels( channels )
2623
, _sampleFormat( sampleFormat )
27-
, _fps( 25. )
24+
, _fps( 1. )
2825
{}
29-
/**
30-
* @warning FPS value is set to 25 by default
31-
*/
26+
3227
AudioFrameDesc( const size_t sampleRate, const size_t channels, const std::string& sampleFormat )
3328
: _sampleRate( sampleRate )
3429
, _channels( channels )
3530
, _sampleFormat( av_get_sample_fmt( sampleFormat.c_str() ) )
36-
, _fps( 25. )
31+
, _fps( 1. )
3732
{}
3833

3934
size_t getSampleRate() const { return _sampleRate; }
@@ -51,7 +46,7 @@ class AvExport AudioFrameDesc
5146
if( _sampleFormat == AV_SAMPLE_FMT_NONE )
5247
throw std::runtime_error( "incorrect sample format" );
5348

54-
size_t size = _sampleRate * _channels * av_get_bytes_per_sample( _sampleFormat );
49+
size_t size = ( _sampleRate / _fps ) * _channels * av_get_bytes_per_sample( _sampleFormat );
5550
if( size == 0 )
5651
throw std::runtime_error( "unable to determine audio buffer size" );
5752

0 commit comments

Comments
 (0)