Is there any way to stream raw bytes of data for a video that is on the camera roll? I am trying to grab a video from the camera roll, and then encrypt it before sending it off. At the moment I am using requestExportSessionForVideo. This works, but it is not as performant as I would like. After the export is done, you will receive a NSURL where the video is located. I would like to skip the step of having to wait while a copy is made. From what I understand, I think iOS is encoding the video and then giving it to you. A 4 minute video takes roughly 45 seconds to process. I can not start the encryption until I have the full video.
What I would like to do is stream the video as is from the camera roll and encrypt the stream. To try to do this I am using requestAVAssetForVideo. Once you have the AVAsset, you can use AVAssetReader and AVAssetWriter to work with the asset. Going down that route I can get a CMSampleBufferRef and I just found this link
How to convert CMSampleBufferRef to NSData
that shows how to convert that to NSData. That example is using the audio data, so I think I could do something similar with the video data. The problem then becomes that the audio and video are split. I know you can use AVAssetWriter to put them back together, but again, that is only working with CMSampleBufferRef, and the output of AVAssetWriter is a NSURL, so I would still have to wait for the full file.
So in short, what I am looking for is a way to get the data from the camera roll, and encrypt it before it is saved to disk. Any ideas?