diff options
Diffstat (limited to 'source/blender/quicktime/apple')
-rw-r--r-- | source/blender/quicktime/apple/qtkit_export.m | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/source/blender/quicktime/apple/qtkit_export.m b/source/blender/quicktime/apple/qtkit_export.m index c22544d1891..b23c768545c 100644 --- a/source/blender/quicktime/apple/qtkit_export.m +++ b/source/blender/quicktime/apple/qtkit_export.m @@ -648,14 +648,24 @@ int append_qt(struct RenderData *rd, int start_frame, int frame, int *pixels, in if (qtexport->audioFile) { UInt32 audioPacketsConverted; + + // Upper limit on total exported audio frames for this particular video frame + const UInt64 exportedAudioFrameLimit = (frame - rd->sfra) * qtexport->audioInputFormat.mSampleRate * rd->frs_sec_base / rd->frs_sec; + /* Append audio */ - while (qtexport->audioTotalExportedFrames < qtexport->audioLastFrame) { + while (qtexport->audioTotalExportedFrames < exportedAudioFrameLimit) { qtexport->audioBufferList.mNumberBuffers = 1; qtexport->audioBufferList.mBuffers[0].mNumberChannels = qtexport->audioOutputFormat.mChannelsPerFrame; qtexport->audioBufferList.mBuffers[0].mDataByteSize = AUDIOOUTPUTBUFFERSIZE; qtexport->audioBufferList.mBuffers[0].mData = qtexport->audioOutputBuffer; - audioPacketsConverted = AUDIOOUTPUTBUFFERSIZE / qtexport->audioCodecMaxOutputPacketSize; + + // Convert one audio packet at a time so that enclosing while loop can + // keep audio processing in sync with video frames. + // Previously, this was set to (AUDIOOUTPUTBUFFERSIZE / qtexport->audioCodecMaxOutputPacketSize), + // however this may cause AudioConverterFillComplexBuffer to convert audio spanning multiple + // video frames, which breaks animation of audio parameters such as volume for fade-in/out. + audioPacketsConverted = 1; err = AudioConverterFillComplexBuffer(qtexport->audioConverter, AudioConverterInputCallback, NULL, &audioPacketsConverted, &qtexport->audioBufferList, qtexport->audioOutputPktDesc); |