Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I ended up abandoning the "read while it's written" approach in favor of a manual chunking approach where I call <code>finishWriting</code> every 5 seconds on a background thread. I was able to drop a negligible number of frames using a method <a href="https://stackoverflow.com/questions/3444791/streaming-video-from-an-iphone?lq=1#comment7593528_3484950">originally described here</a>:</p> <pre><code>- (void) segmentRecording:(NSTimer*)timer { AVAssetWriter *tempAssetWriter = self.assetWriter; AVAssetWriterInput *tempAudioEncoder = self.audioEncoder; AVAssetWriterInput *tempVideoEncoder = self.videoEncoder; self.assetWriter = queuedAssetWriter; self.audioEncoder = queuedAudioEncoder; self.videoEncoder = queuedVideoEncoder; //NSLog(@"Switching encoders"); dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ [tempAudioEncoder markAsFinished]; [tempVideoEncoder markAsFinished]; if (tempAssetWriter.status == AVAssetWriterStatusWriting) { if(![tempAssetWriter finishWriting]) { [self showError:[tempAssetWriter error]]; } } if (self.readyToRecordAudio &amp;&amp; self.readyToRecordVideo) { NSError *error = nil; self.queuedAssetWriter = [[AVAssetWriter alloc] initWithURL:[self newMovieURL] fileType:(NSString *)kUTTypeMPEG4 error:&amp;error]; if (error) { [self showError:error]; } self.queuedVideoEncoder = [self setupVideoEncoderWithAssetWriter:self.queuedAssetWriter formatDescription:videoFormatDescription bitsPerSecond:videoBPS]; self.queuedAudioEncoder = [self setupAudioEncoderWithAssetWriter:self.queuedAssetWriter formatDescription:audioFormatDescription bitsPerSecond:audioBPS]; //NSLog(@"Encoder switch finished"); } }); } </code></pre> <p>Full source code: <a href="https://github.com/chrisballinger/FFmpeg-iOS-Encoder/blob/master/AVSegmentingAppleEncoder.m" rel="nofollow noreferrer">https://github.com/chrisballinger/FFmpeg-iOS-Encoder/blob/master/AVSegmentingAppleEncoder.m</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload