Recording audio channel from a video playing with 'MPMoviePlayerController'


I would like to know if I can record the audio from a playing video using 'MPMoviePlayerController'. if so, how can I do it?



  • Hi Eran,

    It is not possible to record audio from a source like MPMoviePlayerController. However, If you would like to access the audio within a video file, you can use AVFoundation. Assuming the NSURL of the video file is videoURL, the code to do that will look something like this:

    AVMutableComposition *composition = [AVMutableComposition composition];

    AVMutableCompositionTrack *audioTrack = [composition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid];

    AVAsset* asset = [AVURLAsset URLAssetWithURL:videoURL options:nil];

    AVAssetTrack *audioAssetTrack = [[asset tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0];

    [audioTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero,asset.duration) ofTrack:audioAssetTrack atTime:kCMTimeZero error:&editError]

    You can then play the composition with an AVPlayer or export it to an audio file using AVAssetExportSession.

    Hope this helps.


  • Hi Chris,
    Thanks for your answer. I will try it...

  • No problem, good luck! There are a lot of great tips for using AVFoundation on Stack Overflow, so you should find what you need after some digging around.

Sign In or Register to comment.