avassetreader

AVAssetReader, how to use with a stream rather than a file?

旧街凉风 提交于 2019-12-24 04:29:15
问题 AVAssetReader is fantastic, but I can only see how to use it with a local asset, a file, or I guess a composition, So, assetReader = try AVAssetReader(asset: self.asset) ... assetReader.addOutput(readerOutput) and so on, Say you have an arriving stream (perhaps Apple's examples of .M3U8 files, https://developer.apple.com/streaming/examples/ ) In fact, can AVAssetReader be used for streams? Or only local files? I just plain cannot find this explained anywhere. (Maybe it's obvious if you're

AVFoundation decode prores4444 movie with alpha channel

六眼飞鱼酱① 提交于 2019-12-23 01:27:11
问题 I'm trying to decode a prores4444 video with alpha channel on iOS with Swift to overlay as a complex animation over a user video and to export it to his library. The AVFoundation documentation is not that great and I'm struggling to find any code examples. When I try to use the code below with AVAssetReaderTrackOutput to decode the video I get an "AVAssetReaderOutput does not currently support compressed output" error. let avAssetReaderVideoCompositionOutput =

Why does CMSampleBufferGetImageBuffer return NULL

谁说胖子不能爱 提交于 2019-12-21 13:40:28
问题 I have built some code to process video files on OSX, frame by frame. The following is an extract from the code which builds OK, opens the file, locates the video track (only track) and starts reading CMSampleBuffers without problem. However each CMSampleBufferRef I obtain returns NULL when I try to extract the pixel buffer frame. There's no indication in iOS documentation as to why I could expect a NULL return value or how I could expect to fix the issue. It happens with all the videos on

AVAssetWriter How to write down-sampled/compressed m4a/mp3 files

筅森魡賤 提交于 2019-12-20 12:38:58
问题 I'm trying to take a local m4a or mp3 file and compress/down-sample this file (for the purposes of making a smaller file). Originally, I was using the AVAssetExportSession to export an AVAsset to a temp directory, but I didn't have any control over compression/down-sampling (you can only use presets, which of them, only .wav file formats support quality degradation). Then, following several examples here on SO, I tried using AVAssetReader/AVAssetWriter to preform this 'export'. I create my

How do I stream AVAsset audio wirelessly form one iOS device to another?

痞子三分冷 提交于 2019-12-19 04:46:42
问题 I'm making something like streaming the audio from iPod library, send the data via network or bluetooth, and playback using audio queue. Thanks for this question and code. Help me a lot. I have two question about it. what should I send from one device to another? CMSampleBufferRef? AudioBuffer? mData? AudioQueueBuffer? packet? I have no idea. When the app finished the playing, it crashed, and I got error (-12733). I just want to know how to handle the errors instead of letting it crash.

Video Encoding using AVAssetWriter - CRASHES

孤者浪人 提交于 2019-12-17 15:29:04
问题 I have a function that is supposed to re-encode a video to a manageable bitrate on iphone/ipad. Here it is: * UPDATED WORKING CODE, NOW WITH AUDIO! :) * -(void)resizeVideo:(NSString*)pathy{ NSString *newName = [pathy stringByAppendingString:@".down.mov"]; NSURL *fullPath = [NSURL fileURLWithPath:newName]; NSURL *path = [NSURL fileURLWithPath:pathy]; NSLog(@"Write Started"); NSError *error = nil; AVAssetWriter *videoWriter = [[AVAssetWriter alloc] initWithURL:fullPath fileType

Reading multiple video files using “AVAssetReaderTrackOutput” simultaneously freaks out OSX

我的未来我决定 提交于 2019-12-13 05:43:33
问题 I need to read all frames from three short video files (3min each) into the memory ( NSArray of CMSampleBufferRef ). I used typical approach with AVAsset , AVAssetReader , AVAssetReaderTrackOutput and calling copyNextSampleBuffer in while loop. It works okay for 1 file - all 3570 samples are loaded. If I try to load two more files (sequentially) - second loads only 1820 samples, third loads 0 with error -1189 (Cannot Open). And I tried both main thread, background thread and designated thread

How to choose the a pixel format type (kCVPixelBufferPixelFormatTypeKey) for use with AVAssetReader?

社会主义新天地 提交于 2019-12-12 10:39:51
问题 We are using AVAssetReader and AVAssetWriter somewhat in the style as noted in Video Encoding using AVAssetWriter - CRASHES basically to read a video what we got from the photo gallery / asset library then writing it at a different bit rate to reduce its size (for eventual network upload). The trick to getting this to work for us was to specify a kCVPixelBufferPixelFormatTypeKey key and value in the outputSettings on AVAssetReaderTrackOutput , something like this: NSDictionary *outputSettings

Unable to export AVPlayerItem

为君一笑 提交于 2019-12-11 08:15:41
问题 I'm using AVQueuePlayer to do playback of a list of videos in our app. I'm trying to cache the videos that are played by AVQueuePlayer so that the video doesn't have to be downloaded each time. So, after the video finishes playing, I attempt to save the AVPlayerItem into disk so next time it's initialized with a local URL. I've tried to achieve this through two approaches: Use AVAssetExportSession Use AVAssetReader and AVAssetWriter. 1) AVAssetExportSession approach This approach works like