iPhone - Separating audio from a video file and sa

2019-02-13 17:07发布

问题:

Does anyone know if it is possible to separate the audio from a video file such as h.264 encode mpeg (or other such formats) and than save that audio data to a separate file such as an mp3 file? This relates to the iPhone SDK.

Any pointers in the right direction would be much appreciated. Thanks.

回答1:

Sounds like a job for AVFoundation. I can't tell you the details, but opening a video file into an AVURLAsset should give you access to its tracks. Identify the tracks whose mediaType is AVMediaTypeAudio.

Not sure about the output part, but I would try creating an AVMutableComposition object to which I'd then add the tracks you want to export. Then use AVAssetExportSession or AVAssetWriter to write the result to a new file.