Slides and stuff from Voices That Matter talk

I wish I hadn’t been so crunched in the week leading up to the Voices That Matter: iPhone Developer Conference last weekend in Philadelphia, and had gotten a few of the super-advanced AV Foundation features working for demos, but since I went over my time by 10 minutes, I guess the talk was already chock ful o’ content.

Anyways, I promised materials would be on my blog after a code clean-up, and here they are:

Title: Mastering Media with AV Foundation

  • Presentation slides (PDF)
  • – Illustrates basic playback functionality, with local and remote files and streams (included URLs include .m4a, .mov, Shoutcast, and HTTP LIve Streaming)
  • – Performs A/V capture from camera/mic and playback of captured movie
  • – Simple cuts-only editor for in/out editing, addition of audio track at export time.

Comments (6)

  1. kmadhukishore

    Hello there,
    First of all thanks for the nice tutorials.
    In my app I want mix one audio file with video file, I am able to do that in simulator, but not in my iPhone 3g 🙁
    Following is the code which I am using:

    NSURL* a_inputFileUrl = nil;
    NSURL* b_inputFileUrl = nil;
    NSString* extStr = [NSString stringWithString:@”mov”];
    NSString* fileName = [[NSBundle mainBundle] pathForResource:@”1″ ofType:extStr];
    a_inputFileUrl = [NSURL fileURLWithPath:fileName];
    NSString* extStr = [NSString stringWithString:@”caf”];
    NSString* fileName = [[NSBundle mainBundle] pathForResource:@”1″ ofType:extStr];
    b_inputFileUrl = [NSURL fileURLWithPath:fileName];
    NSString* outputFilePath = nil;
    NSString* storeUrlStr = [[self applicationDocumentsDirectory] stringByAppendingPathComponent:@”temp”];
    NSFileManager* fileManager = [NSFileManager defaultManager];
    [fileManager createDirectoryAtPath:storeUrlStr withIntermediateDirectories:NO attributes:nil error:nil];
    outputFilePath = [storeUrlStr stringByAppendingPathComponent:[NSString stringWithString:@””]];
    outputFileUrl = [[NSURL fileURLWithPath:outputFilePath] retain];

    AVURLAsset* audioAsset = [[AVURLAsset alloc]initWithURL:b_inputFileUrl options:nil];
    AVURLAsset* videoAsset = [[AVURLAsset alloc]initWithURL:a_inputFileUrl options:nil];

    AVMutableComposition* mixComposition = [AVMutableComposition composition];

    AVMutableCompositionTrack *compositionCommentaryTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeTimedMetadata
    [compositionCommentaryTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, audioAsset.duration)
    ofTrack:[[audioAsset tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0]
    atTime:kCMTimeZero error:nil];

    AVMutableCompositionTrack *compositionVideoTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo
    [compositionVideoTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, videoAsset.duration)
    ofTrack:[[videoAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]
    atTime:kCMTimeZero error:nil];

    _assetExport = [[AVAssetExportSession alloc] initWithAsset:mixComposition
    NSURL* exportUrl = outputFileUrl;

    if ([[NSFileManager defaultManager] fileExistsAtPath:outputFilePath])
    [[NSFileManager defaultManager] removeItemAtPath:outputFilePath error:nil];

    _assetExport.outputFileType = @””;
    _assetExport.outputURL = exportUrl;
    _assetExport.shouldOptimizeForNetworkUse = YES;

    [_assetExport exportAsynchronouslyWithCompletionHandler:
    ^(void ) {


  2. […] this is twice in a row that I’ve done a talk for the Voices That Matter: iPhone Developer Conference and been able […]

  3. […],, – see Slides and stuff from Voices That Matter talk […]

  4. Hi ,
    Thanks for the best tutorial i have found !
    I have a question Can we only record video with black or white color / blend color ?

  5. Rafeeq

    Nice tutorial thanks for that,

    I have a question , How can we delete the selected part of video and play or store rest of the video.

  6. Akhii

    Great Tutorial buddy
    @Rafeeq Try to join two Asset. Its may be work….

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.