jigneshbrahmkhatri
jigneshbrahmkhatri

Reputation: 3637

certain movie frames edit using GPUImage

I want to apply effects on certain frames of movie using GPUImage. I have successfully added effect on entire movie file, so is there a way to add different effects on different frames?

For example, I want to apply effect of Sepia on video from 5 seconds to 10 seconds. So I need 0-5 seconds to be original video, 5-10 seconds with Sepia effect and 10 - video total seconds with original video.

Also, I want to draw text/image on certain frames using GPUImage, is it possible?

Any response will be greatly appreciated.

Upvotes: 3

Views: 983

Answers (1)

Brandon Schlenker
Brandon Schlenker

Reputation: 5088

You could ask MPMoviePlayerController or AVAssetImageGenerator to generate a thumbnail at the time you specify.

iPhone Read UIimage (frames) from video with AVFoundation

AVAssetImageGenerator provides images rotated

If you'd like videos instead of just frames, you could trim a section out of the video and apply an effect to that. This takes the URL of your video and trims it to the specified time.

    AVURLAsset *videoAsset = [AVURLAsset URLAssetWithURL:videoURL options:nil]; 
    AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:videoAsset presetName:AVAssetExportPresetHighestQuality];
    exportSession.outputURL = [NSURL fileURLWithPath:outputURL];
    exportSession.outputFileType = AVFileTypeQuickTimeMovie;
    CMTimeRange timeRange = CMTimeRangeMake(CMTimeMake(startMilliseconds, 1000), CMTimeMake(endMilliseconds - startMilliseconds, 1000));
    exportSession.timeRange = timeRange;

    [exportSession exportAsynchronouslyWithCompletionHandler:^{
        switch (exportSession.status) {
            case AVAssetExportSessionStatusCompleted:
                 ///
                // Call something to apply the effect
               ///
                break;
            case AVAssetExportSessionStatusFailed:
                NSLog(@"Failed:%@", exportSession.error);
                break;
            case AVAssetExportSessionStatusCancelled:
                NSLog(@"Canceled:%@", exportSession.error);
                break;
            default:
                break;
        }
    }];

Upon completion, you'd then apply your effect and if you went with the video clip route, combine them, and encode them.

How to combine video clips with different orientation using AVFoundation

Upvotes: 1

Related Questions