Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: QTKit Capture APIs, custom compression settings and synch
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: QTKit Capture APIs, custom compression settings and synch



Thanks for your answer David.

I will explore the possibility to record to two separate files (the original idea was to merge the two streams on the fly). I will then load both streams, read the video stream QTSampleBuffer by QTSampleBuffer and add audio samples according to the read presentationTime in order to get a properly synchronized movie. I will report back.

Ivan Guajana



On 9-feb-08, at 01:34, David Underwood wrote:

Hi Ivan.

The QTCaptureDecompressedVideoOutput  delegate method

- (void)captureOutput:(QTCaptureOutput *)captureOutput didOutputVideoFrame:(CVImageBufferRef)videoFrame withSampleBuffer: (QTSampleBuffer *)sampleBuffer fromConnection:(QTCaptureConnection *)connection;

and the QTCaptureMovieFileOutput delegate method

- (void)captureOutput:(QTCaptureFileOutput *)captureOutput didOutputSampleBuffer:(QTSampleBuffer *)sampleBuffer fromConnection: (QTCaptureConnection *)connection;

both provide a QTSampleBuffer object which contains the sample data and media metadata for the sample being captured. You can use QTSampleBuffer's presentationTime method to extract the presentation time stamps from each sample buffer you receive. All sample buffers captured within a QTCaptureSession are time stamped from a single time base, so if you record audio and video samples to separate files, you can synchronize the two movies when you combine them by comparing the presentation times of the original sample buffers.

If you go the route of writing your own movie file, you should probably stick with the lower level ICMCompressionSession APIs. addImage:forDuration:... does not maintain a session between invocations, and therefore will not effectively compress to formats with dependent frames, such as H.264. This is not a problem for still image codecs, such a jpeg, however.

David Underwood
QuickTime Engineering

On Jan 25, 2008, at 6:22 AM, Ivan Guajana wrote:

Hello everybody,
first of all, let me thank people at Apple for the new QTKit Capture APIs, which are making my life easier. I could already spare several thousand lines of code in our app dealing with device detection/selection/audio metering/etc by just replacing the legacy QT calls with the new APIs and I even got more functionality/ efficiency.


Using the new APIs, however, I noticed that there are very limited possibilities to choose the output codec/bitrate/size when using QTMovieFileOutput. I decided to use an instance of QTCaptureDecompressedVideoOutput instead and compress the incoming frames using an ICMCompressionSession. The problem is that I have to store the compressed video frames along with the audio (which should also be compressed somehow) in a synchronized fashion. How can I carry this out? I read something about using QTSampleBuffer to do this. Can someone provide me with some pointers/pseudocode?

Furthermore, what would be better/worse if I used QTKit's addImage:forDuration approach instead of ICMCompressionSession? Would it be at all feasible?

Thank you very much in advance

Ivan

--
SWITCH
Serving Swiss Universities
------------------------------------
Ivan Guajana, NetServices
P.O. Box, 8021 Zürich, Switzerland
phone +41 44 268 15 85, fax +41 44 268 15 68
email@hidden, http://www.switch.ch


_______________________________________________ Do not post admin requests to the list. They will be ignored. QuickTime-API mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden


-- SWITCH Serving Swiss Universities ------------------------------------ Ivan Guajana, NetServices P.O. Box, 8021 Zürich, Switzerland phone +41 44 268 15 85, fax +41 44 268 15 68 email@hidden, http://www.switch.ch


Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
QuickTime-API mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: QTKit Capture APIs, custom compression settings and synch (From: David Underwood <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.