AVAudioPlayer stops playing immediately with ARC

The problem is that when compiling with ARC you need to make sure to keep a reference to instances that you want to keep alive as the compiler will automatically fix “unbalanced” alloc by inserting release calls (at least conceptually, read Mikes Ash blog post for more details). You can solve this by assigning the … 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

iOS AVFoundation: How do I fetch artwork from an mp3 file?

I found that the artworks were being loaded asynchronously while the image was being set synchronously. I solved it this way: – (void)metadata { AVURLAsset *asset = [AVURLAsset URLAssetWithURL:self.fileURL options:nil]; NSArray *titles = [AVMetadataItem metadataItemsFromArray:asset.commonMetadata withKey:AVMetadataCommonKeyTitle keySpace:AVMetadataKeySpaceCommon]; NSArray *artists = [AVMetadataItem metadataItemsFromArray:asset.commonMetadata withKey:AVMetadataCommonKeyArtist keySpace:AVMetadataKeySpaceCommon]; NSArray *albumNames = [AVMetadataItem metadataItemsFromArray:asset.commonMetadata withKey:AVMetadataCommonKeyAlbumName keySpace:AVMetadataKeySpaceCommon]; AVMetadataItem *title = [titles … Read more

How to combine video clips with different orientation using AVFoundation

This is what I do. I then use an AVAssetExportSession to create the actual file. but I warn you, the CGAffineTransforms are sometimes applied late, so you’ll see a or two of the original before the video transforms. I have no clue why this happens, a different combination of videos will yield the expected result, … Read more

AVCaptureSession with multiple previews

I ran into the same problem of needing multiple live views displayed at the same time. The answer of using UIImage above was too slow for what I needed. Here are the two solutions I found: 1. CAReplicatorLayer The first option is to use a CAReplicatorLayer to duplicate the layer automatically. As the docs say, … Read more