- (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];
...
}
When I use the above method to synthesize the video, the color changes.
Preview effect:
And demo is Here. https://github.com/qdvictory/TestForSyncthesizeVideo
Can someone tell me what the cause is?