Editing some video frames using GPUImage

I want to apply effects to specific frames of a movie using GPUImage. I have successfully added an effect to the entire video file, so is there a way to add different effects for different frames?

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

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

Any answer would be greatly appreciated.

+3
source share
1 answer

You can ask MPMoviePlayerController or AVAssetImageGenerator to create a sketch at the time you specify.

iPhone UIimage () AVFoundation

AVAssetImageGenerator

, , . URL .

    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;
        }
    }];

, , , .

AVFoundation

+1

All Articles