@AVFoundationEngineers I browsed through AVCustomEdit sample code and notice the following:
- (void)startVideoCompositionRequest:(AVAsynchronousVideoCompositionRequest *)request
{
@autoreleasepool {
dispatch_async(_renderingQueue,^() {
// Check if all pending requests have been cancelled
if (_shouldCancelAllRequests) {
[request finishCancelledRequest];
} else {
NSError *err = nil;
// Get the next rendererd pixel buffer
CVPixelBufferRef resultPixels = [self newRenderedPixelBufferForRequest:request error:&err];
if (resultPixels) {
// The resulting pixelbuffer from OpenGL renderer is passed along to the request
[request finishWithComposedVideoFrame:resultPixels];
CFRelease(resultPixels);
} else {
[request finishWithError:err];
}
}
}
}
The startVideoComposition request returns early without calling finishWithComposedVideoFrame as the processing takes place asynchronously in a dispatchQueue. However, the documentation of startVideoCompositionRequest states the following:
Note that if the custom compositor's implementation of -startVideoCompositionRequest: returns without finishing the composition immediately, it may be invoked again with another composition request before the prior request is finished; therefore in such cases the custom compositor should be prepared to manage multiple composition requests.
But I don't see anything in the code that is prepared to handle multiple composition requests of same video frame. How is one supposed to handle this case?