if (self.assetWriter.status == AVAssetWriterStatusUnknown ||
self.assetWriter.status == AVAssetWriterStatusCompleted ||
self.assetWriter.status == AVAssetWriterStatusCancelled ||
self.assetWriter.status == AVAssetWriterStatusFailed) {
}else {
[self.assetWriterVideoInput markAsFinished];
[self.assetWriterAudioInput markAsFinished];
[self.assetWriterAudioAppInput markAsFinished];
[self.assetWriter endSessionAtSourceTime:endTime];
}
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
__weak typeof(self)weakSelf = self;
[_encoder.assetWriter finishWritingWithCompletionHandler:^{
weakSelf.encoder.assetWriterVideoInput = nil;
weakSelf.encoder.assetWriterAudioInput = nil;
weakSelf.encoder.assetWriterAudioAppInput = nil;
weakSelf.encoder.assetWriter = nil;
dispatch_semaphore_signal(semaphore);
}];
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);