AVFoundation + AssetWriter: Generate Movie With Images and Audio

I ended up exporting the video separately using the above code and added the audio files separately using AVComposition & AVExportSession. Here is the code -(void) addAudioToFileAtPath:(NSString *) filePath toPath:(NSString *)outFilePath { NSError * error = nil; AVMutableComposition * composition = [AVMutableComposition composition]; AVURLAsset * videoAsset = [AVURLAsset URLAssetWithURL:[NSURL fileURLWithPath:filePath] options:nil]; AVAssetTrack * videoAssetTrack = … Read more

iOS AVFoundation: Setting Orientation of Video

Finally,based on the answers of @Aaron Vegh and @Prince, I figured out my resolution: //Converting video +(void)convertMOVToMp4:(NSString *)movFilePath completion:(void (^)(NSString *mp4FilePath))block{ AVURLAsset * videoAsset = [[AVURLAsset alloc]initWithURL:[NSURL fileURLWithPath:movFilePath] options:nil]; AVAssetTrack *sourceAudioTrack = [[videoAsset tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0]; AVMutableComposition* composition = [AVMutableComposition composition]; AVMutableCompositionTrack *compositionAudioTrack = [composition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid]; [compositionAudioTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, videoAsset.duration) ofTrack:sourceAudioTrack atTime:kCMTimeZero error:nil]; AVAssetExportSession * assetExport … Read more

Reading samples via AVAssetReader

It’s unclear from your question whether you are talking about video samples or audio samples. To read video samples, you need to do the following: Construct an AVAssetReader: asset_reader = [[AVAssetReader alloc] initWithAsset:asset error:&error]; (error checking goes here) Get the video track(s) from your asset: NSArray* video_tracks = [asset tracksWithMediaType:AVMediaTypeVideo]; AVAssetTrack* video_track = [video_tracks objectAtIndex:0]; … Read more

AVPlayer And Local Files

I decided to answer my own question because I felt like there is very little documentation on how to use the Apple provided AVPlayer for both local and stream (over http) files. To help understand the solution, I put together a sample project on GitHub in Objective-C and Swift The code below is Objective-C but … Read more

How to apply a Vignette CIFilter to a live camera feed in iOS?

Your step 2 is way too slow to support real-time rendering… and it looks like you’re missing a couple of steps. For your purpose, you would typically: Setup: create a pool of CVPixelBuffer – using CVPixelBufferPoolCreate create a pool of metal textures using CVMetalTextureCacheCreate For each frame: convert CMSampleBuffer > CVPixelBuffer > CIImage Pass that … Read more