I export a series of still images to a movie using AVFoundation.
Despite I always set the codec to AVVideoCodecTypeAppleProRes4444, sometimes I get a movie with the AppleProRes4444 format, and sometimes, if I change the image sources, I get a movie with the H.264 format.
I never change the codec, so I would like to know whether AVFoundation can autonomously change my codec.
If no, as I presume, I would like to understand what I miss here.
Despite I always set the codec to AVVideoCodecTypeAppleProRes4444, sometimes I get a movie with the AppleProRes4444 format, and sometimes, if I change the image sources, I get a movie with the H.264 format.
I never change the codec, so I would like to know whether AVFoundation can autonomously change my codec.
If no, as I presume, I would like to understand what I miss here.
Code Block videoWriter = [[AVAssetWriter alloc] initWithURL:[NSURL fileURLWithPath:moviePath] fileType:AVFileTypeQuickTimeMovie error:&error]; NSParameterAssert(videoWriter); if(videoWriter == nil) return NO; NSString *codec = AVVideoCodecTypeAppleProRes4444; NSMutableDictionary *videoSettings = [NSMutableDictionary dictionaryWithObjectsAndKeys: codec, AVVideoCodecKey, width, AVVideoWidthKey, height, AVVideoHeightKey, nil]; videoWriterInput = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo outputSettings:videoSettings]; NSParameterAssert(videoWriterInput); if(videoWriterInput == nil) return NO; NSDictionary *bufferSettings = [NSDictionary dictionaryWithObjectsAndKeys:NumI(kCVPixelFormatType_444YpCbCr10BiPlanarVideoRange), kCVPixelBufferPixelFormatTypeKey, nil]; adaptor = [AVAssetWriterInputPixelBufferAdaptor assetWriterInputPixelBufferAdaptorWithAssetWriterInput:videoWriterInput sourcePixelBufferAttributes:bufferSettings]; if(adaptor == nil) return NO; NSParameterAssert([videoWriter canAddInput:videoWriterInput]); videoWriterInput.expectsMediaDataInRealTime = YES; [videoWriter addInput:videoWriterInput]; [videoWriter startWriting]; [videoWriter startSessionAtSourceTime:kCMTimeZero]; /* Then I add the images with */ [adaptor appendPixelBuffer:buffer withPresentationTime:CMTimeMake((int64_t)counter, (int32_t)fps)]; /* I previously created the buffer with */ CVPixelBufferCreate(kCFAllocatorDefault, width, height, kCVPixelFormatType_32BGRA, nil, &bufferRef); aRGBABuffer = CVPixelBufferGetBaseAddress(bufferRef); rowBytes = CVPixelBufferGetBytesPerRowOfPlane(bufferRef, 0); aRGBAContext = CGBitmapContextCreate(aRGBABuffer, iWidth, iHeight, 8, rowBytes, CGColorSpaceCreateDeviceRGB(), (CGBitmapInfo)kCGImageAlphaPremultipliedLast);