Created
September 5, 2012 12:33
-
-
Save pita5/3635925 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[audioReader startReading]; | |
// Go back to the beginning of the video to append the audio | |
[videoWriter startSessionAtSourceTime:kCMTimeZero]; | |
// Get the next block of date of the audio | |
CMSampleBufferRef sample; | |
// Keep appending the audio as it becomes ready | |
while ((sample = [readerOutput copyNextSampleBuffer])) | |
{ | |
// Wait for the audio writer to be ready | |
while (![audioWriterInput isReadyForMoreMediaData]) {} | |
// Append to audio writer with input | |
[audioWriterInput appendSampleBuffer:sample]; | |
// Cleanup | |
CFRelease(sample); | |
sample = NULL; | |
} | |
// Finish the video at the source time | |
[videoWriter endSessionAtSourceTime:CMTimeMake(duration-1, 2)]; | |
// Finish | |
[videoWriter finishWriting]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment