- 您好,我正在研究仅从
audio
文件video
中提取。 - 那在
< iOS 8.0
版本中有效,但在版本中无效>= iOS 8.0
。 - 如何提取
>= iOS 8.0
版本中的音频?
问问题
2209 次
1 回答
6
使用 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);
}];
}
在 outputUrl 处处理文件以供进一步使用。:)
于 2015-02-21T16:09:45.893 回答