Goal:
Use AVCaptureMovieFileOutput
to record video to a .mov file. While video is recording, I want to upload it to S3. The uploading part should be feasible with Multi-Part upload. (Mac OS X +10.8 app)
Problem:
How do I read from a .mov file in chunks, while the file is being written to with AVCaptureMovieFileOutput
and growing in size?
What I did so far:
// session = AVCaptureSession with audio and video inputs
fileOutput = [[AVCaptureSession alloc] init];
[session addOutput:fileOutput]
[session startRunning]
[fileOutput startRecordingToOutputFileURL: fileUrl recordingDelegate:self]
// In async dispatch queue
inputStream = [NSInputStream inputStreamWithFileAtPath:fileUrl]
// schedule in run loop, open and run
At this point I start receiving stream:handleEvent:
messages on the delegate object with NSStreamEventHasBytesAvailable
. But after a few seconds the messages stops coming in (after total bytes of 250.000-300.000 bytes (0.2MB)) This happens even though the .mov file grows in size to >10MB.
Questions:
Why does the
NSInputStream
delegate not continue to receive stream events?Is the data available initially not reliable?
Is this overall a feasible approach? Or is there another way of achieving what I want?
Thanks!