- (void)makeVideoWithImages:(NSArray *)images seconds:(CGFloat)seconds block:(void (^)(NSString *videopath)) block {
...
UIImage *source = [images objectAtIndex:0];
CGSize size = CGSizeMake(source.size.width*source.scale, source.size.height*source.scale);
videoSettings = @{AVVideoCodecKey : AVVideoCodecH264,
AVVideoWidthKey : [NSNumber numberWithInt:size.width],
AVVideoHeightKey : [NSNumber numberWithInt:size.height]};
self.outputWriter = [[AVAssetWriter alloc] initWithURL:url
fileType:AVFileTypeQuickTimeMovie error:&error];
self.outputWriterInput = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo
outputSettings:videoSettings];
[self.outputWriter addInput:self.outputWriterInput];
NSDictionary *bufferAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:kCVPixelFormatType_32RGBA], kCVPixelBufferPixelFormatTypeKey, nil];
self.bufferAdapter = [[AVAssetWriterInputPixelBufferAdaptor alloc] initWithAssetWriterInput:self.outputWriterInput sourcePixelBufferAttributes:bufferAttributes];
frameTime = CMTimeMake(seconds*600, 600);
[self.outputWriter startWriting];
[self.outputWriter startSessionAtSourceTime:kCMTimeZero];
...
}
ビデオを合成するために上記の方法を使用すると、色が変わります。画像を使用してビデオを作成するときの色ずれAVFoundation
プレビュー効果:
そしてデモはここにあります。 https://github.com/qdvictory/TestForSyncthesizeVideo
誰かが原因を教えてもらえますか?
私は 'kCVPixelFormatType_32RGBA'の色範囲を変更する可能性について考えていましたが、入力フォーマットが何であるかを説明するのではなく、変換を行っているかどうかはわかりませんでした –
また、 Objective-Cは私の答えを信頼できないものにします。しかし、私は、この問題はかなり言語にとらわれないものに由来していると信じています –