Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to use AVAssetWriter to write h264 strem into video?
    primarykey
    data
    text
    <p>I want to make the h.264 stream from server to a video file, but when I used <code>assetwrite.finishwrite</code>, the XCode reports</p> <pre><code>Video /var/mobile/Applications/DE4196F1-BB77-4B7D-8C20-7A5D6223C64D/Documents/test.mov cannot be saved to the saved photos album: Error Domain=NSOSStatusErrorDomain Code=-12847 "This movie format is not supported." UserInfo=0x5334830 {NSLocalizedDescription=This movie format is not supported.}" </code></pre> <p>Below is my code: data is the h.264 frame, just one frame, it might be i frame or p.</p> <pre><code>(void)_encodeVideoFrame2:(NSData *) data time:(double)tm { CMBlockBufferRef videoBlockBuffer=NULL; CMFormatDescriptionRef videoFormat=NULL; CMSampleBufferRef videoSampleBuffer=NULL; CMItemCount numberOfSampleTimeEntries=1; CMItemCount numberOfSamples=1; CMVideoFormatDescriptionCreate(kCFAllocatorDefault, kCMVideoCodecType_H264, 320, 240, NULL, &amp;videoFormat); OSStatus result; result=CMBlockBufferCreateWithMemoryBlock(kCFAllocatorDefault, NULL, data.length, kCFAllocatorDefault, NULL, 0, data.length, kCMBlockBufferAssureMemoryNowFlag, &amp;videoBlockBuffer); result=CMBlockBufferReplaceDataBytes(data.bytes, videoBlockBuffer, 0, data.length); CMSampleTimingInfo videoSampleTimingInformation={CMTimeMake(tm*600, 600)}; size_t sampleSizeArray[1]; sampleSizeArray[0]=data.length; result=CMSampleBufferCreate(kCFAllocatorDefault, videoBlockBuffer, TRUE, NULL, NULL, videoFormat, numberOfSamples, numberOfSampleTimeEntries, &amp;videoSampleTimingInformation, 1, sampleSizeArray, &amp;videoSampleBuffer); result = CMSampleBufferMakeDataReady(videoSampleBuffer); [assetWriterInput appendSampleBuffer:videoSampleBuffer]; } </code></pre> <p>maybe the <code>CMSampleBufferCreate</code> arguments are wrong? Thank you.</p>
    singulars
    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.
    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