我有一个录制的视频,我想将其保存为ios sdk中1.5播放速度(快进)的新视频。任何人都可以建议我如何实现这一功能?
由于 Yashesh
答案 0 :(得分:4)
AVURLAsset* videoAsset = nil; //self.inputAsset;
//create mutable composition
AVMutableComposition *mixComposition = [AVMutableComposition composition];
AVMutableCompositionTrack *compositionVideoTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo
preferredTrackID:kCMPersistentTrackID_Invalid];
NSError *videoInsertError = nil;
BOOL videoInsertResult = [compositionVideoTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, videoAsset.duration)
ofTrack:[[videoAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]
atTime:kCMTimeZero
error:&videoInsertError];
if (!videoInsertResult || nil != videoInsertError) {
//handle error
return;
}
//slow down whole video by 2.0
double videoScaleFactor = 2.0;
CMTime videoDuration = videoAsset.duration;
[compositionVideoTrack scaleTimeRange:CMTimeRangeMake(kCMTimeZero, videoDuration)
toDuration:CMTimeMake(videoDuration.value*videoScaleFactor, videoDuration.timescale)];
//export
AVAssetExportSession* assetExport = [[AVAssetExportSession alloc] initWithAsset:mixComposition
presetName:AVAssetExportPresetLowQuality];
答案 1 :(得分:0)
检查
NSBundle *bundle = [NSBundle mainBundle];
NSString *moviePath = [bundle pathForResource:titleOfButton ofType:@"mov"];
NSURL *movieURL = [ NSURL fileURLWithPath:moviePath];
MPMoviePlayerController *themovie = [[MPMoviePlayerController alloc]initWithContentURL: movieURL];
[themovie play];
[themovie setCurrentPlaybackRate:2.f];