Iphone 如何在AVMutableComposition中使用scaleTimeRange?

Iphone 如何在AVMutableComposition中使用scaleTimeRange?,iphone,ios,objective-c,ipad,avfoundation,Iphone,Ios,Objective C,Ipad,Avfoundation,我有一个关于在AVMUTABLE合成中缩放视频长度以加速或减慢它的问题。我知道做这件事的准则是 scaleTimeRange:(CMTimeRange)timeRange toDuration:(CMTime)duration 问题是我不知道如何使用这些代码。我目前为我的作品所做的是,它有一个录制的视频曲目和一个提供的音频曲目 有人能告诉我如何添加这个,让我的视频轨道加快或减慢 这是我的密码: AVURLAsset* audioAsset = [[AVURLAsset alloc]initWi

我有一个关于在AVMUTABLE合成中缩放视频长度以加速或减慢它的问题。我知道做这件事的准则是

scaleTimeRange:(CMTimeRange)timeRange toDuration:(CMTime)duration
问题是我不知道如何使用这些代码。我目前为我的作品所做的是,它有一个录制的视频曲目和一个提供的音频曲目

有人能告诉我如何添加这个,让我的视频轨道加快或减慢

这是我的密码:

AVURLAsset* audioAsset = [[AVURLAsset alloc]initWithURL:audioURL options:nil];
AVURLAsset* videoAsset = [[AVURLAsset alloc]initWithURL:videoURL options:nil];    

AVMutableComposition* mixComposition = [AVMutableComposition composition];

AVMutableCompositionTrack *compositionCommentaryTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeAudio 
                                                                                    preferredTrackID:kCMPersistentTrackID_Invalid];
[compositionCommentaryTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, videoAsset.duration) 
                                    ofTrack:[[audioAsset tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0] 
                                     atTime:kCMTimeZero error:nil];

AVMutableCompositionTrack *compositionVideoTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo 
                                                                               preferredTrackID:kCMPersistentTrackID_Invalid];
[compositionVideoTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, videoAsset.duration) 
                               ofTrack:[[videoAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0] 
                                atTime:kCMTimeZero error:nil];

AVAssetExportSession* _assetExport = [[AVAssetExportSession alloc] initWithAsset:mixComposition 
                                                                      presetName:AVAssetExportPresetPassthrough];   

NSString* videoName = @\"export.mov\";

NSString *exportPath = [NSTemporaryDirectory() stringByAppendingPathComponent:videoName];
NSURL    *exportUrl = [NSURL fileURLWithPath:exportPath];

如果问题中有任何信息缺失或不清楚,请告诉我。你解决了吗?:)