From fd0ad3c8df4c426f341703931e5db30a658ee2d8 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 4 May 2013 13:17:43 +0000 Subject: Fix quicktime video export not properly supporting animation of audio properties like volume. Patch #35184 by James Yonan, see the report for a detailed explanation of why this failed. --- source/blender/quicktime/apple/qtkit_export.m | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'source/blender/quicktime') 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); -- cgit v1.2.3