From c1abebca9717d55da5283a4bf53cbae594d0d70e Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Sun, 17 Sep 2017 14:32:19 +0200 Subject: [PATCH] Fix mismatch between a track timescale and the samplerate used by the audio decoder. --- MP42/MP42AudioDecoder.m | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/MP42/MP42AudioDecoder.m b/MP42/MP42AudioDecoder.m index dc6cd44..628326c 100644 --- a/MP42/MP42AudioDecoder.m +++ b/MP42/MP42AudioDecoder.m @@ -276,8 +276,8 @@ static AVPacket * packetFromSampleBuffer(MP42SampleBuffer *sample) AVPacket *pkt = av_packet_alloc(); pkt->data = sample->data; pkt->size = sample->size; - pkt->pts = sample->decodeTimestamp; - pkt->dts = AV_NOPTS_VALUE; + pkt->dts = sample->decodeTimestamp; + pkt->duration = sample->duration; return pkt; } @@ -354,10 +354,9 @@ static void configureDescriptors(MP42DecodeContext *context, AVFrame *frame) context->inputFormat->mSampleRate = sample_rate; if (sample_rate > 48000) { - sample_rate = 48000; + context->outputFormat->mSampleRate = sample_rate; } - context->outputFormat->mSampleRate = sample_rate; context->outputFormat->mBytesPerPacket = 4 * context->outputFormat->mChannelsPerFrame; context->outputFormat->mBytesPerFrame = context->outputFormat->mBytesPerPacket * context->outputFormat->mFramesPerPacket;