Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone - Separating audio from a video file and saving it to a separate file

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.

like image 323
Zigglzworth Avatar asked Aug 12 '11 15:08

Zigglzworth


1 Answers

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.

like image 147
Ole Begemann Avatar answered Oct 28 '22 09:10

Ole Begemann