1 objective-c avassetexportsession avmetadataitem ios8
audio从video文件。< iOS 8.0版本中有效,但在版本中无效>= iOS 8.0。>= iOS 8.0版本中的音频?使用AVAssetExportSession将视频文件转换为音频。您可以使用此方法。
- (void)convertVideoToAudioWithInputURL:(NSURL*)inputURL
outputURL:(NSURL*)outputURL
handler:(void (^)(AVAssetExportSession*))handler
{
AVURLAsset* asset = [AVURLAsset URLAssetWithURL:inputURL options:nil];
self.exportSession = [[AVAssetExportSession alloc] initWithAsset:asset
presetName: AVAssetExportPresetPassthrough];
self.exportSession.outputURL = outputURL;
self.exportSession.outputFileType = AVFileTypeAppleM4A; //For audio file
self.exportSession.timeRange = CMTimeRangeMake(kCMTimeZero, [asset duration]);
[self.exportSession exportAsynchronouslyWithCompletionHandler:^(void) {
handler(self.exportSession);
}];
}
Run Code Online (Sandbox Code Playgroud)
在outputUrl处处理文件以备将来使用。:)
| 归档时间: |
|
| 查看次数: |
1586 次 |
| 最近记录: |