简体   繁体   中英

Trimming ALAsset video using UIVideoEditorController

I am having an ALAsset object of type video. I would like to trim this video using UIVideoEditorController. Following is the code snippet:

UIVideoEditorController *videoEditorController = [[UIVideoEditorController alloc] init];
videoEditorController.delegate = self;
videoEditorController.videoMaximumDuration = 0.0;
videoEditorController.videoQuality = UIImagePickerControllerQualityTypeHigh;
videoEditorController.videoPath = @"assets-library://asset/asset.MOV?id=1000000005&ext=MOV";
[inViewController presentModalViewController:videoEditorController animated:YES];
self.videoEditController = videoEditorController;
[videoEditorController release];

When the UI of UIVideoEditorController is pushed I get an error 'This movie could not be played'. What is the problem here?

Are you testing the video on iPhone 3Gs or iPhone 4? Make sure video is compatible to play on 3Gs. I'm sure this is the problem only.

Below is code snippet ....

ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];

NSString *filePathString = [[NSBundle mainBundle] pathForResource:@"Don2" ofType:@"m4v"];
NSURL *filePathURL = [NSURL fileURLWithPath:filePathString isDirectory:NO];
if ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:filePathURL]) {
    [library writeVideoAtPathToSavedPhotosAlbum:filePathURL completionBlock:^(NSURL *assetURL, NSError *error){
        if (error) {
            // TODO: error handling
            NSLog(@"Error");
        } else {
            // TODO: success handling
        }
    }];
}
[library release];

videoEditorController.videoMaximumDuration = 0.0; ? Did you mean - videoEditorController.videoMaximumDuration = 1000.0; ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM