How to get Url of Slow motion file from Asset?

I am getting a normal video url file, but the slow motion video object type is AVComposition

. I'm trying with. AVAssetExportSession

But it takes a long time.

PHVideoRequestOptions *options=[[PHVideoRequestOptions alloc] init];
options.version = PHVideoRequestOptionsVersionCurrent;
options.networkAccessAllowed = YES;

[[PHImageManager defaultManager] requestAVAssetForVideo:asset options:options resultHandler:^(AVAsset *avAsset, AVAudioMix *audioMix, NSDictionary *info) {

     if(([avAsset isKindOfClass:[AVComposition class]] && ((AVComposition *)avAsset).tracks.count == 2)) {

         //Output URL of the slow motion file.
         NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
         NSString *documentsDirectory = paths.firstObject;
         NSString *myPathDocs =  [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"mergeSlowMoVideo-%d.mov",arc4random() % 1000]];
         NSURL *url = [NSURL fileURLWithPath:myPathDocs];

         //Begin slow mo video export
         AVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset:avAsset presetName:AVAssetExportPresetHighestQuality];
         exporter.outputURL = url;
         exporter.outputFileType = AVFileTypeQuickTimeMovie;
         exporter.shouldOptimizeForNetworkUse = YES;

         [exporter exportAsynchronouslyWithCompletionHandler:^{

             dispatch_async(dispatch_get_main_queue(), ^{
                 if (exporter.status == AVAssetExportSessionStatusCompleted) {
                 }
             });
         }];
     } else if ([avAsset isKindOfClass:[AVURLAsset class]]) {
     }
 }];

      

+3
ios objective-c iphone avasset


source to share


No one has answered this question yet

Check out similar questions:

1276
How can I disable ARC for one file in a project?
928
How do I call Objective-C code from Swift?
240
Is Simulated Slow Animation Enabled Now?
233
How do I get the device and device model on iOS?
209
Why is viewWillAppear not called when the app returns from the background?
185
How to encode url string
17
How to make slow video on iOS
1
the problem is in entering vlaues into the database
1
Problem fetching data from sqlite
1
Black screen For video game url comes from Server Side



All Articles
Loading...
X
Show
Funny
Dev
Pics