AVAssetWriterVideoInput을 사용하여 파일에 버퍼를 추가하고 있습니다.AVAssetWriterVideoInput을 사용하여 비디오 파일에 프레임을 추가하지 못했습니다. 끝 부분에 문서화되지 않은 오류 -12738이 발생합니다.
if (_assetWriter.status == AVAssetWriterStatusWriting) {
// If the asset writer status is writing, append sample buffer to its corresponding asset writer input
if (mediaType == AVMediaTypeVideo) {
if (_assetWriterVideoInput.readyForMoreMediaData) {
if (![_assetWriterVideoInput appendSampleBuffer:sampleBuffer]) {
NSLog(@"error: %@", [_assetWriter.error localizedFailureReason]);
NSLog(@"error: %@", [_assetWriter.error localizedRecoveryOptions]);
NSLog(@"error: %@", [_assetWriter.error localizedDescription]);
NSLog(@"error: %@", [_assetWriter.error domain]);
NSLog(@"error: %@", [_assetWriter.error userInfo]);
} else
NSLog(@"frame saved");
}
}
모든 사과 문서 예상대로, 분명, 어떤 documentation에 발견되지
if (![_assetWriterVideoInput appendSampleBuffer:sampleBuffer]) {
이 unknown error
코드 -12738
실패이 라인 :이 코드가 있습니다.
또한 AVFoundation 내에 알려지지 않은 오류에 대한 코드가 많고 시스템이 -12738
코드를 선택하는 경우 알 수없는 것보다 더 많이 알 수 있다는 간단한 이유 때문에 알 수없는 오류라고 의심됩니다.
저장되는 파일을 보면 버퍼/프레임이 저장되지 않기 때문에 0 메가 바이트가 유지됩니다.
이 AVAssetWriterVideoInput
CMVideoDimensions dimensions = CMVideoFormatDescriptionGetDimensions(currentFormatDescription);
NSUInteger numPixels = dimensions.width * dimensions.height;
NSUInteger bitsPerSecond;
// Assume that lower-than-SD resolutions are intended for streaming, and use a lower bitrate
NSUInteger bitsPerPixel = 11.4; // This bitrate matches the quality produced by AVCaptureSessionPresetHigh.
bitsPerSecond = numPixels * bitsPerPixel;
NSDictionary *videoCompressionSettings = @{AVVideoCodecKey : AVVideoCodecH264,
AVVideoWidthKey : @(dimensions.width),
AVVideoHeightKey : @(dimensions.height),
AVVideoCompressionPropertiesKey : @{ AVVideoAverageBitRateKey : @(bitsPerSecond),
AVVideoMaxKeyFrameIntervalKey : @(30)} };
if ([_assetWriter canApplyOutputSettings:videoCompressionSettings forMediaType:AVMediaTypeVideo])
{
// Intialize asset writer video input with the above created settings dictionary
_assetWriterVideoInput = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo outputSettings:videoCompressionSettings];
_assetWriterVideoInput.expectsMediaDataInRealTime = YES;
버퍼는, 다음과 같은 특징이 있습니다 :
CMSampleBuffer 0x1009e12a0 retainCount: 1 allocator: 0x1b762cbb8
invalid = NO
dataReady = YES
makeDataReadyCallback = 0x0
makeDataReadyRefcon = 0x0
formatDescription = <CMVideoFormatDescription 0x[0x1b762cbb8]> {
mediaType:'vide'
mediaSubType:'BGRA'
mediaSpecific: {
codecType: 'BGRA' dimensions: 1920 x 1080
}
extensions: {<CFBasicHash 0x17087c2c0 [0x1b762cbb8]>{type = immutable dict, count = 2,
entries =>
0 : <CFString 0x1b1c6d460 [0x1b762cbb8]>{contents = "Version"} = <CFNumber 0xb000000000000022 [0x1b762cbb8]>{value = +2, type = kCFNumberSInt32Type}
2 : <CFString 0x1b1c6d3e0 [0x1b762cbb8]>{contents = "CVBytesPerRow"} = <CFNumber 0xb00000000001e002 [0x1b762cbb8]>{value = +7680, type = kCFNumberSInt32Type}
}
}
}
sbufToTrackReadiness = 0x0
numSamples = 1
sampleTimingArray[1] = {
{PTS = {290309939228910/1000000000 = 290309.939}, DTS = {INVALID}, duration = {INVALID}},
}
imageBuffer = 0x170321180
I have a sample code here 문제를 선택하십시오. 이 코드는 4K로 비디오를 촬영할 준비가되어 있습니다. 장치가 그것을 할 수없는 경우 라인 AVCaptureSessionPreset3840x2160
을 AVCaptureSessionPresetHigh inside
ProcessadorVideo.m`로 변경하십시오. 샘플 코드는 비디오 스트림에서 사각형을 자르고 만화 효과를 적용합니다. 감사합니다.
'startSessionAtSourceTime'을 (를) 호출 하시겠습니까? –
다른 질문 (http://stackoverflow.com/a/41207678/22147)과 비슷한 문제입니까? –
지연 응답을 위해 미안 : 아니오. 그것을 시도했다. 문제가 지속됩니다. – SpaceDog