0

I need to be able take a video from Photos and re-rendering, both clipping it in time, changing the width and height, and frame rate. Certainly I need to start with:

    PHContentEditingInputRequestOptions *options = [[PHContentEditingInputRequestOptions alloc] init];

    [self.asset requestContentEditingInputWithOptions:options completionHandler:^(PHContentEditingInput *contentEditingInput, NSDictionary *info) {

        // Get full image

        NSURL *url = [contentEditingInput fullSizeImageURL];

    }];

And I should be able to adjust width, height and duration. Grab an NSData from that, write that out to the file syset.m

But the url is nil, which implies to me that I can't edit videos with the new Photos framework. (ALAsset didn't have a problem with this using AVAssetExportSession.) This makes sense since the Apple Dev sample code can't edit videos either.

Now, to make life easier I could just pass that url to an AVAssetExportSession but I can't, because it is nil. If I just modified width, height and duration I'd still need to grab an NSData from it, write that out to the file system.

I do not need to write the modified video back to Photos, I actually need the video on the file system since I'll be uploading it to our servers.

Paul Cezanne
  • 8,629
  • 7
  • 59
  • 90

1 Answers1

2

fullSizeImageURL is for working with Photo assets. You want the avAsset property when working with a video. Modify the actual video, not the metadata, by writing a new video file.

To do that, you could use that avAsset in an AVMutableComposition:

Insert the appropriate time range of the avAsset's video track (AVAssetTrack) into an AVMutableCompositionTrack. That'll do your trimming.

Place/size it appropriately using layer instructions. (AVMutableVideoCompositionLayerInstruction) to do your cropping and scaling.

jlw
  • 3,166
  • 1
  • 19
  • 24
  • I had just assumed that AVAssets would be, well, deprecated since Photos.framework came out. This makes my life super easy, since my code already uses AVAssets. I'll check it out on Monday. Thanks! – Paul Cezanne Sep 26 '14 at 22:14
  • No problem. It is ALAssets that are deprecated, not AVAssets. Separate frameworks. – jlw Sep 26 '14 at 22:15
  • upvoted a random answer of yours since you've made my Monday easier! – Paul Cezanne Sep 26 '14 at 22:36