由于视频是一组图片,因此您可以在创建新视频后裁剪视频中的所有帧.AVFoundation指南描述了一些任务:全部放在一起:将视频帧捕获为UIImage对象 之后,您可以裁剪 图像并编写视频
您可以使用资产编写器从样本缓冲区或静止图像等媒体生成QuickTime影片文件或MPEG-4文件.
有关详细信息,请参阅AV Foundation Framework
[[NSFileManager defaultManager] removeItemAtURL:outputURL error:nil];
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:inputURL options:nil];
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetLowQuality];
exportSession.outputURL = outputURL;
exportSession.shouldOptimizeForNetworkUse = YES;
exportSession.outputFileType = AVFileTypeQuickTimeMovie;
CMTime start = CMTimeMakeWithSeconds(1.0, 600);
CMTime duration = CMTimeMakeWithSeconds(120.0, 600);
CMTimeRange range = CMTimeRangeMake(start, duration);
exportSession.timeRange = range;
[exportSession exportAsynchronouslyWithCompletionHandler:^(void){
handler(exportSession);
[exportSession release];}];
Run Code Online (Sandbox Code Playgroud)
这里我们得到前2分钟的视频.