File tree Expand file tree Collapse file tree 3 files changed +5
-15
lines changed Expand file tree Collapse file tree 3 files changed +5
-15
lines changed Original file line number Diff line number Diff line change @@ -25,9 +25,6 @@ AudioFrameDesc AudioCodec::getAudioFrameDesc() const
25
25
{
26
26
assert ( _avCodecContext != NULL );
27
27
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 );
31
28
return audioFrameDesc;
32
29
}
33
30
@@ -36,9 +33,6 @@ void AudioCodec::setAudioParameters( const AudioFrameDesc& audioFrameDesc )
36
33
_avCodecContext->sample_rate = audioFrameDesc.getSampleRate ();
37
34
_avCodecContext->channels = audioFrameDesc.getChannels ();
38
35
_avCodecContext->sample_fmt = audioFrameDesc.getSampleFormat ();
39
- _avCodecContext->time_base .num = 1 ;
40
- _avCodecContext->time_base .den = audioFrameDesc.getFps ();
41
- _avCodecContext->ticks_per_frame = 1 ;
42
36
}
43
37
44
38
}
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ AudioGenerator::~AudioGenerator()
20
20
void AudioGenerator::setAudioFrameDesc ( const AudioFrameDesc& frameDesc )
21
21
{
22
22
_frameDesc = frameDesc;
23
+ _frameDesc.setFps ( 25 . );
23
24
}
24
25
25
26
void AudioGenerator::setFrame ( Frame& inputFrame )
Original file line number Diff line number Diff line change @@ -17,23 +17,18 @@ namespace avtranscoder
17
17
class AvExport AudioFrameDesc
18
18
{
19
19
public:
20
- /* *
21
- * @warning FPS value is set to 25 by default
22
- */
23
20
AudioFrameDesc ( const size_t sampleRate = 0 , const size_t channels = 0 , const AVSampleFormat sampleFormat = AV_SAMPLE_FMT_NONE )
24
21
: _sampleRate( sampleRate )
25
22
, _channels( channels )
26
23
, _sampleFormat( sampleFormat )
27
- , _fps( 25 . )
24
+ , _fps( 1 . )
28
25
{}
29
- /* *
30
- * @warning FPS value is set to 25 by default
31
- */
26
+
32
27
AudioFrameDesc ( const size_t sampleRate, const size_t channels, const std::string& sampleFormat )
33
28
: _sampleRate( sampleRate )
34
29
, _channels( channels )
35
30
, _sampleFormat( av_get_sample_fmt( sampleFormat.c_str() ) )
36
- , _fps( 25 . )
31
+ , _fps( 1 . )
37
32
{}
38
33
39
34
size_t getSampleRate () const { return _sampleRate; }
@@ -51,7 +46,7 @@ class AvExport AudioFrameDesc
51
46
if ( _sampleFormat == AV_SAMPLE_FMT_NONE )
52
47
throw std::runtime_error ( " incorrect sample format" );
53
48
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 );
55
50
if ( size == 0 )
56
51
throw std::runtime_error ( " unable to determine audio buffer size" );
57
52
You can’t perform that action at this time.
0 commit comments