Skip to content

Commit 61c4d80

Browse files
author
Clement Champetier
committed
AudioReader: fix description of the src audio frame desc
If the user asks to decode only one channel in the audio stream, the src frame should have the corresponding description (if not, the transform that follow won't be the one expected).
1 parent dd8ae36 commit 61c4d80

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/AvTranscoder/reader/AudioReader.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,14 @@ void AudioReader::init()
4545
_currentDecoder = _decoder;
4646

4747
// create src frame
48-
const AudioFrameDesc srcFrameDesc = _inputFile->getStream(_streamIndex).getAudioCodec().getAudioFrameDesc();
48+
AudioFrameDesc srcFrameDesc = _inputFile->getStream(_streamIndex).getAudioCodec().getAudioFrameDesc();
49+
if(_channelIndex != -1)
50+
srcFrameDesc._nbChannels = 1;
4951
_srcFrame = new AudioFrame(srcFrameDesc, false);
5052
AudioFrame* srcFrame = static_cast<AudioFrame*>(_srcFrame);
5153
// create dst frame
5254
_outputSampleRate = srcFrame->getSampleRate();
53-
_outputNbChannels = (_channelIndex == -1) ? srcFrame->getNbChannels() : 1;
55+
_outputNbChannels = srcFrame->getNbChannels();
5456
_dstFrame = new AudioFrame(AudioFrameDesc(_outputSampleRate, _outputNbChannels, getSampleFormatName(_outputSampleFormat)));
5557

5658
// generator

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy