我用UIVideoEditorController来修剪视频。编辑后,在委托中,我尝试将视频与其他媒体混合。然而,[AVURLAsset trackWithMediaType:]无法找到视频跟踪。守则如下:
- (void)video:(NSString*)videoPath didFinishSavingWithError:(NSError*)error contextInfo:(void*)contextInfo {
NSURL *videoURL = [NSURL URLWithString:videoPath];
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:videoURL options:nil];
if(asset == nil) {
NSLog(@"Cannot create AVURLAsset");
return;
} else {
NSLog(@"Asset: %@", asset);
}
if([asset tracksWithMediaType:AVMediaTypeVideo].count == 0) {
NSLog(@"No Video Track");
return;
} else if([asset tracksWithMediaType:AVMediaTypeAudio].count == 0) {
NSLog(@"No Audio Track");
return;
}
// Follow up codes hidden intentionally
}控制台日志打印:
2014-10-15 13:35:45.913 TestVideoTrim[3278:1191544] Asset: <AVURLAsset: 0x178229e00, URL = /private/var/mobile/Containers/Data/Application/96E7C0FF-92EB-44F7-8E35-B29FD0E58302/tmp/trim.EC3FB214-9907-411D-B3A3-75 ... 41E5.MOV>
2014-10-15 13:35:45.981 TestVideoTrim[3278:1191544] No Video Track然而,当我去照片应用程序和播放修剪的视频,视频播放良好的音频。找不到视频音轨的原因是什么?
附注:委托函数的NSError返回null,表示编辑视频时没有发生错误。
发布于 2015-09-29 09:45:28
替换
NSURL *videoURL = [NSURL URLWithString:videoPath];使用
NSURL *videoURL = [NSURL fileURLWithPath:videoPath];https://stackoverflow.com/questions/26375295
复制相似问题