I set AVVideoCodecTypeAppleProRes4444 and I get a AVVideoCodecTypeH264 movie

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.


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);



I have just discovered the cause of the trouble. If I added a soundtrack to the movie, the 4444ProRes codec unexpectedly turned into an H.264 codec. So, I have just replaced

[[AVAssetExportSession alloc] initWithAsset:videoAudioComposition presetName:AVAssetExportPresetHighestQuality];

with

[[AVAssetExportSession alloc] initWithAsset:videoAudioComposition presetName:AVAssetExportPresetAppleProRes4444LPCM];

and now it works well. I can quite get a movie with 4444 ProRes codec and the audio tracks.

The only point I miss now is that the AVAssetExportPresetAppleProRes4444LPCM is available on macOS 10.15+.

Which preset could I use on macOS 10.13 ?

I set AVVideoCodecTypeAppleProRes4444 and I get a AVVideoCodecTypeH264 movie
 
 
Q