UIVideoEditorController を使用してビデオをトリミングしようとしています。トリミングまたは保存した後、UIVideoEditorController を使用するとビデオの解像度が失われました。以前UIImagePickerController
は、解像度を設定してビデオを撮影UIImagePickerControllerQualityTypeIFrame1280x720
し、プロパティ videoQuality を (iPhone 5) に設定して URL パスを UIVideoEditorController に設定していましたUIImagePickerControllerQualityTypeIFrame1280x720
。AVFoudation フレームワークを使用してビデオをキャプチャすると、同じ効果が得られます。解像度が失われたのはなぜですか? 私のコード:
if ([UIVideoEditorController canEditVideoAtPath:self.videoPath]) {
//video quality 1280x720
self.editor = [UIVideoEditorController new];
self.editor.videoPath = self.videoPath;
self.editor.videoMaximumDuration = 180.0;
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_5_0
self.editor.videoQuality =
UIImagePickerControllerQualityTypeIFrame1280x720;
#elif __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0
self.editor.videoQuality =
UIImagePickerControllerQualityType640x480; // VGA quality
#endif
self.editor.delegate = self;
[self.navigationController presentViewController:self.editor
animated:NO
completion:nil];
} else {
DLog(@"can't edit video at %@", self.videoPath);
}
デリゲートで:
- (void)videoEditorController:(UIVideoEditorController *)editor
didSaveEditedVideoToPath:(NSString *)editedVideoPath {
[self removeImage:editor.videoPath];
[editor dismissViewControllerAnimated:YES
completion:^{
}];
#if DEBUG
AVAssetTrack *videoTrack = nil;
AVURLAsset *asset =
[AVAsset assetWithURL:[NSURL fileURLWithPath:editedVideoPath]];
NSArray *videoTracks = [asset tracksWithMediaType:AVMediaTypeVideo];
CMFormatDescriptionRef formatDescription = NULL;
NSArray *formatDescriptions = [videoTrack formatDescriptions];
if ([formatDescriptions count] > 0)
formatDescription =
(__bridge CMFormatDescriptionRef)[formatDescriptions objectAtIndex : 0];
if ([videoTracks count] > 0)
videoTrack = [videoTracks objectAtIndex:0];
CGSize trackDimensions = {
.width = 0.0, .height = 0.0,
};
trackDimensions = [videoTrack naturalSize];
int width = trackDimensions.width;
int height = trackDimensions.height;
DLog(@"Resolution = %d X %d", width, height); <- 640x320
#endif
if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(editedVideoPath)) {
[self convertVideo:[NSURL fileURLWithPath:editedVideoPath]];
} else {
DLog(@"cannot save video on path %@", editedVideoPath);
}
}