Note that there are some explanatory texts on larger screens.

plurals
  1. POAVAssetWriter finishWriting failing and producing videos that can only be watched for 50%
    primarykey
    data
    text
    <p>I am currently capturing video and audio using AVCaptureSession and have set up the pipeline to write out the data to disk using an AVAssetWriter. For short videos this is working fine absolutely no issues. </p> <p>However if the length of the recorded media goes over some arbitrary time, usually around 2 minutes then the call to finish writing fails but still manages to produce a video file that only plays back around 50% of its content. I continuously call isReadyForMoreMediaData and appendSampleBuffer during writing and they always returns true. I seem to get no notification that something has gone wrong until the finishWriting call.</p> <p>The AVAssetWriters Error is set to the following after the failed finishWriting call</p> <pre><code>Capture failed to end with status 3 and error Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo=0x210b7880 {NSLocalizedFailureReason=An unknown error occurred (268451843), NSUnderlyingError=0x210b1ee0 "The operation couldn’t be completed. (OSStatus error 268451843.)", NSLocalizedDescription=The operation could not be completed} </code></pre> <p>Not the most useful error in the world...</p> <p>This is followed shortly by a call to the AVCaptureSessionRuntimeErrorNotification listener that I have set up which contains the error</p> <pre><code>Error Domain=AVFoundationErrorDomain Code=-11819 "Cannot Complete Action" UserInfo=0x21011940 {NSLocalizedRecoverySuggestion=Try again later., NSLocalizedDescription=Cannot Complete Action} </code></pre> <p>Again not very helpful...</p> <p>This is the code i Use to configure the AVAssetWriter input for audio</p> <pre><code> //\Configure Audio Writer Input AudioChannelLayout acl; bzero(&amp;acl, sizeof(acl)); acl.mChannelLayoutTag = kAudioChannelLayoutTag_Stereo; NSDictionary* audioOutputSettings = [NSDictionary dictionaryWithObjectsAndKeys: [ NSNumber numberWithInt: kAudioFormatMPEG4AAC], AVFormatIDKey, [ NSNumber numberWithInt: 2 ], AVNumberOfChannelsKey, [ NSNumber numberWithFloat: 44100.0 ], AVSampleRateKey, [ NSData dataWithBytes: &amp;acl length: sizeof( AudioChannelLayout ) ], AVChannelLayoutKey, [ NSNumber numberWithInt: 64000 ], AVEncoderBitRateKey, nil]; m_audioWriterInput = [[AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeAudio outputSettings:audioOutputSettings] retain]; </code></pre> <p>This is the code I use to configure the AVAssetWriterInput for video</p> <pre><code> videoSettings = [NSDictionary dictionaryWithObjectsAndKeys: AVVideoCodecH264, AVVideoCodecKey, [NSNumber numberWithInt:640], AVVideoWidthKey, [NSNumber numberWithInt:480], AVVideoHeightKey, nil]; m_videoWriterInput = [[AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo outputSettings:videoSettings] retain]; m_videoWriterInput.expectsMediaDataInRealTime = YES; </code></pre> <p>This is the code i use to initialise the AVAssetWriter</p> <pre><code> m_audioAndVideoWriter = [[AVAssetWriter alloc] initWithURL:[NSURL fileURLWithPath:outputPath] fileType:AVFileTypeQuickTimeMovie error:&amp;error]; m_audioAndVideoWriter.shouldOptimizeForNetworkUse = YES; [m_audioAndVideoWriter addInput:m_videoWriterInput]; [m_audioAndVideoWriter addInput:m_audioWriterInput]; </code></pre> <p>Has anyone experienced similar issues? Or know what stuff goes on inside the finishWriting call that might cause this issue? or maybe someone knows some novel ways of debugging this issue?</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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.
 

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