Questions tagged [avassetreader]

You use an AVAssetReader object to obtain media data of an asset, whether the asset is file-based or represents an assemblage of media data from multiple sources (as with an AVComposition object).

AVAssetReader lets you:

Read raw un-decoded media samples directly from storage, obtain samples decoded into renderable forms. Mix multiple audio tracks of the asset and compose multiple video tracks (by using AVAssetReaderAudioMixOutput and AVAssetReaderVideoCompositionOutput). AVAssetReader’s pipelines are multithreaded internally. After you initiate reading with initWithAsset:error:, a reader loads and processes a reasonable amount of sample data ahead of use so that retrieval operations such as copyNextSampleBuffer (AVAssetReaderOutput) can have very low latency. Note, however, that AVAssetReader is not intended for use with real-time sources, and its performance is not guaranteed for real-time operations.

Click Here for Apple documentation.

98 questions
20
votes
1 answer

Video Encoding using AVAssetWriter - CRASHES

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…
box86rowh
  • 3,415
  • 2
  • 26
  • 37
13
votes
2 answers

Reading samples via AVAssetReader

How do you read samples via AVAssetReader? I've found examples of duplicating or mixing using AVAssetReader, but those loops are always controlled by the AVAssetWriter loop. Is it possible just to create an AVAssetReader and read through it, getting…
13
votes
2 answers

Can't continue reading from AVAssetReaderOutput after going to background and back to foreground

I'm using an AVAssetReaderOutput to read samples from an AVAsset, do some processing on them, and play the result using a RemoteIO AU. The problem is that after calling AudioOutputUnitStop to pause the playback, then after going to the background…
Danra
  • 9,546
  • 5
  • 59
  • 117
11
votes
2 answers

Sample accurate extraction of chunks of audio using AVFoundation

Problem I am looking to extract sample-accurate ranges of LPCM audio from audio tracks within video files. Currently, I'm looking to achieve this using AVAssetReaderTrackOutput against an AVAssetTrack delivered from reading a AVURLAsset. Despite…
Dan
  • 1,258
  • 1
  • 10
  • 22
10
votes
1 answer

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

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…
Dfowj
  • 739
  • 9
  • 25
9
votes
4 answers

AVAssetReaderOutput copyNextSampleBuffer hangs when encoding video w/ audio on device

After implementing the solution to encoding video (with audio) in this question, Video Encoding using AVAssetWriter - CRASHES, I found that the code works correctly in the iPhone Simulator. Unfortunately, certain videos fail to encode their audio…
jlw
  • 3,166
  • 1
  • 19
  • 24
8
votes
1 answer

Getting value from unSafeMutablePointer Int16 in Swift for audio data purposes

I'm working to convert to Swift this code which helps get me get audio data for visualizations. The code I'm working with in Obj C, which works well, is: while (reader.status == AVAssetReaderStatusReading) { AVAssetReaderTrackOutput…
MScottWaller
  • 3,321
  • 2
  • 24
  • 47
8
votes
1 answer

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

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…
Chris Markle
  • 2,076
  • 4
  • 25
  • 46
7
votes
1 answer

Playing video on iOS using OpenGL-ES

I'm trying to play a video (MP4/H.263) on iOS, but getting really fuzzy results. Here's the code to initialize the asset reading: mTextureHandle = [self createTexture:CGSizeMake(400,400)]; NSURL * url = [NSURL fileURLWithPath:file]; mAsset =…
arul
  • 13,998
  • 1
  • 57
  • 77
7
votes
1 answer

Swift 2 : AVAssetReader and NSInputStream Audio Graph

I'm trying to convert an example from Bob McCune's Learning AVFoundation book and having some issues using AVAssetReader and NSInputStream. The graph should be a pure sine wave but the values seem reflected on the X-axis somehow. I've tried every…
Justin Levi Winter
  • 2,327
  • 2
  • 17
  • 30
7
votes
1 answer

AVfoundation Reverse Video

I tried to make video in reverse. While playing asset in AVPlayer i set the rate = -1 to make it work in reverse format. But how to export that video? I looked into docs. read about avassetwrite, sambuffers , compositions but didn't find any way to…
7
votes
3 answers

Why does CMSampleBufferGetImageBuffer return NULL

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…
Dave Durbin
  • 3,562
  • 23
  • 33
6
votes
1 answer

How to get the timestamp of each video frame in iOS while decoding a video.mp4

Scenario: I am writing an iOS app to try decode a videoFile.mp4. I am using AVAssetReaderTrackOutput with AVAssetReader to decode frames from the video file. This works very well. I get each & every frame from videoFile.mp4 basically using the…
TheWaterProgrammer
  • 7,055
  • 12
  • 70
  • 159
4
votes
3 answers

How to correctly read decoded PCM samples on iOS using AVAssetReader -- currently incorrect decoding

I am currently working on an application as part of my Bachelor in Computer Science. The application will correlate data from the iPhone hardware (accelerometer, gps) and music that is being played. The project is still in its infancy, having worked…
Peter
  • 53
  • 1
  • 1
  • 4
4
votes
1 answer

AVAssetReader fails after the app is put in the background, why?

I have playback working with AVAssetReader and iPod library and when I put the the app in the background it will continue reading in audio to the playback buffer but when it gets to the end of a song and starts reading on the next song it fails when…
Brennan
  • 11,546
  • 16
  • 64
  • 86
1
2 3 4 5 6 7