Questions tagged [avasset]

AVAsset is an abstract class to represent timed audiovisual media such as videos and sounds. Each asset contains a collection of tracks that are intended to be presented or processed together, each of a uniform media type, including but not limited to audio, video, text, closed captions, and subtitles.

An AVAsset object defines the collective properties of the tracks that comprise the asset. (You can access the instances of AVAssetTrack representing tracks of the collection, so you can examine each of these independently if you need to.) You often instantiate an asset using a concrete subclass of AVAsset; for example, you can initialize an instance of AVURLAsset using an URL that refers to an audiovisual media file, such as a QuickTime movie file or an MP3 file (amongst other types). You can also instantiate an asset using other concrete subclasses that extend the basic model for audiovisual media in useful ways, as AVComposition does for temporal editing. To assemble audiovisual constructs from one or more source assets, you can insert assets into instances of AVMutableComposition.

You often instantiate an asset using AVURLAsset—a concrete subclass of AVAsset—with URLs that refer to audiovisual media resources, such as streams (including HTTP live streams), QuickTime movie files, MP3 files, and files of other types. You can also instantiate an asset using other concrete subclasses that extend the basic model for audiovisual media in useful ways, as AVComposition does for temporal editing.

Properties of assets as a whole are defined by AVAsset. Additionally, references to instances of AVAssetTrack representing tracks of the collection can be obtained, so that each of these can be examined independently.

Because of the nature of timed audiovisual media, upon successful initialization of an asset some or all of the values for its keys may not be immediately available. The value of any key can be requested at any time, and asset will always return its value synchronously, although it may have to block the calling thread in order to do so. In order to avoid blocking, you can register your interest in particular keys and to become notified when their values become available. For further details, see AVAsynchronousKeyValueLoading.

To play an instance of AVAsset, initialize an instance of AVPlayerItem with it, use the player item to set up its presentation state (such as whether only a limited timeRange of the asset should be played, etc.), and provide the player item to an AVPlayer object according to whether the item is to be played by itself or together with a collection of other items.

Click Here for Apple documentation.

399 questions
0
votes
1 answer

Can we play more than one video from a single AVAsset instance iOS

I referred the docs and it says that you may create multiple AVPlayerLayer instances from a single AVAsset object but it nowhere says if we can play more than one video from a single AVAsset instance. I don't think its possible but still I'm not…
Reckoner
  • 1,041
  • 2
  • 13
  • 29
0
votes
0 answers

AVAssetWriter fails when audio Compression Settings are set

When I have audioCompressionSettings as nil in the following code, AVAssetWriterInput* audioWriterInput = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeAudio outputSettings:nil sourceFormatHint:(__bridge…
Nat
  • 300
  • 3
  • 8
0
votes
1 answer

Objective C/IOS - AVAsset - Error

I'm trying to use the following code to save a snippet of audio from a url stream (e.g., a radio station broadcast): float vocalStartMarker = 0.0; float vocalEndMarker = 20.0; NSURL *audioFileInput = [[NSURL alloc] initWithString:…
Baz
  • 41
  • 5
0
votes
0 answers

Converting NSString which was read from a file to NSURL to create AVAsset in Swift

At Obj-C we were reading a file and converting its NSString content to NSURL to get AVAsset which was saved as absoluteString beforehand. audioAssetURL = [NSURL URLWithString:[readNSString…
Hope
  • 2,096
  • 3
  • 23
  • 40
0
votes
0 answers

Impossible to trim an AVAsset in Swift?

I'd like to trim a video which is the only track in my AVAsset. I'd like to change the duration attribute of it but It's in read only and I haven't found any other way on the web to trim my AVAsset without exporting it. I tried to move the playhead…
YoanGJ
  • 479
  • 5
  • 25
0
votes
1 answer

Modify bitrate in AVAsset for cordova Video Editor

I need to reduce the dimension of a video taken with an hybrid app without reduce the resolution therefore I'm trying to modify the cordova video editor plugin to reduce the dimension of the video by changing the bitrate. I've tried to use…
OneZeroOne
  • 157
  • 1
  • 10
0
votes
2 answers

"unexpectedly found nil while unwrapping an Optional value" when I try to get a CGImage by AVAssetImageGenerator

I'm trying to make a thumbnail image of UIImage from PHLivePhoto so that I can get a moment before or after the picture captured. I'm struggling with the error: unexpectedly found nil while unwrapping an Optional value at cgImage = try?…
Justin Sato
  • 523
  • 1
  • 4
  • 20
0
votes
1 answer

Trimming video with Monotouch fails with "The operation could not be completed"

I am trying to trim a video to 5 seconds programmatically. Here is my implementation. AVAssetExportSession exportSession= new AVAssetExportSession(videoAsset,AVAssetExportSession.PresetLowQuality.ToString()); int SystemVersion =…
Sreeraj
  • 2,306
  • 2
  • 18
  • 31
0
votes
1 answer

AVPlayer rotates portrait video to landscape

I am recording videos with AVcapture and playing them in an AVplayer. NSURL *videoUrl1 = [self.mediaInfo objectAtIndex:0]; AVURLAsset *videoAsset1 = [AVURLAsset URLAssetWithURL:videoUrl1 options:nil]; NSURL *videoUrl2 = [self.mediaInfo…
Zeretyh
  • 17
  • 1
  • 6
0
votes
1 answer

AVAssetTrack with alpha channel?

I am trying to layer AVAssetTracks in an AVMutableComposition where the AVAssetTracks have an alpha channel in the video. I have successfully exported an video AVAsset with pixel buffers than have an alpha channel and transparency, but when I try to…
tomgerhardt
  • 711
  • 1
  • 4
  • 5
0
votes
1 answer

iOS Change keyframes in video

I'm trying to scrub through videos in really small values (maybe even less than milliseconds). To get to the next frame I use [AVPlayer seekToTime:time toleranceBefore: kCMTimeZero toleranceAfter:kCMTimeZero] which gives me the correct position. The…
Jan
  • 1,827
  • 2
  • 16
  • 29
0
votes
0 answers

Extract audio from a video file saved in the camera roll

I have the following code that reads a video file from the camera roll which works perfectly fine Scene *scene = [_sceneArray objectAtIndex:0]; NSString *path = scene.src_url; NSURL *full_url = [[NSURL alloc] initFileURLWithPath:path]; AVURLAsset…
Yrol
  • 159
  • 4
  • 17
0
votes
2 answers

How to mix audio with video in ios?

Im trying to mix one audio file with Video file, but i got an error. " Export failed: The operation could not be completed " Please correct this code if there is an error. My Code: -(void)CompileFilesToMakeMovie { AVMutableComposition*…
Anand
  • 3,346
  • 9
  • 35
  • 54
0
votes
0 answers

ios - AVAssetWriter Writes Video but does not record AUDIO

I have been successfull in making viedo (though Blur) but have been Unsuccessful in recording audio Please Help. I am using the following code Pls go through it ans suggest some solution or a working tutorial. I am Appending the Sample Buffer…
iAviatorJose
  • 418
  • 2
  • 10
  • 25
0
votes
2 answers

AVAsset incorrect length

I need to play remote mp3 files in my app. I'm using AVURLAsset and AVPlayer to do it. Everything is fine, but some files has incorrect length. I need correct length to display progress bar of track playback. Here is mp3 file with wrong…
frozen_lion
  • 648
  • 5
  • 18
1 2 3
26
27