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
0 answers

AVPlayer averagePower(forChannel:)

I'm using an AVPlayer and I'm looking for the averagePower(forChannel:) equivalent of AVAudioPlayer and AVAudioRecorder. I need it to make some visual audio animations.
Marie Dm
  • 2,637
  • 3
  • 24
  • 43
0
votes
2 answers

Convert AVMetadataItem's GPS string into a CLLocation

An AVAsset (or AVURLAsset) contains AVMetadataItems in an array, of which one may be of the common key AVMetadataCommonKeyLocation. The value of that item is a string which appears in a format like: +39.9410-075.2040+007.371/ How do you convert…
Danny
  • 397
  • 3
  • 9
0
votes
1 answer

AVAsset video size (width * height)

I capture a screen record and output it to an file. And My mac is retina. I get the file size by: self.asset = [AVAsset assetWithURL:_assetURL]; AVAssetTrack *track = [[self.asset tracksWithMediaType:AVMediaTypeVideo]…
melody5417
  • 355
  • 2
  • 13
0
votes
2 answers

Cache videos in tableview

I want to cache videos that are displayed in a tableview. However, I am not sure what to cache. I'm using AVFoundation, in particular I'm using AVPlayer and creating AVPlayerItem's. My question is: what do I cache? Is it the AVPlayer, AVPlayerItem,…
JEL
  • 1,540
  • 4
  • 23
  • 51
0
votes
1 answer

How to get a video PHAsset disk file size?

I'm trying to determine the file size on disk of a PHAsset video. The following code is returning am error "The file “IMG_0188.mov” couldn’t be opened because you don’t have permission to view it." PHVideoRequestOptions *options =…
user1752054
  • 372
  • 4
  • 17
0
votes
1 answer

Custom video size causes error in AVAssetWriter

I used the below code to render a simple video with a red rectangle. Everything works fine with _CanvasSize = CGSizeMake(320, 200);. However, the video is tearing if I change the size to _CanvasSize = CGSizeMake(321, 200); or (100, 100). Does anyone…
Incpt.Mobis
  • 199
  • 1
  • 2
  • 11
0
votes
1 answer

iOS requestExportSessionForVideo exports video without metadata

I use requestExportSessionForVideo for exporting video located in iPhone to document directory. I gave options and exportpreset to export the exactly same video saved in camera roll. But the result is little bit different. When I compare it with…
Hwangho Kim
  • 629
  • 4
  • 20
0
votes
1 answer

Deleting File Path extension don't work, when we have to convert video format from .MOV to .MP4

As i select a video from Gallery i am getting selected file extension as .MOV so wanted to convert it to .MP4 researched but not getting how to do that in this case. If u have any idea please help. -…
vicky
  • 253
  • 2
  • 14
0
votes
1 answer

AVAsset's "isPlayable" / "playable" check blocks and delays UI updates

In my app at some point the user can invoke video playing with tapping on an UI element, and then the following code segment will be executed: self.loadingView.frame = _frameWhereItShouldBeLocated; [self.loadSpinner startAnimating]; //…
peakingcube
  • 1,388
  • 15
  • 32
0
votes
1 answer

AVAsset rotation

It's a well documented issue on SO, where AVAssets get rotated after writing them to file, either using AVAssetWriter or AVComposition. And there are solutions, such as looking at the video track transform and seeing how the asset is rotated so that…
barndog
  • 6,975
  • 8
  • 53
  • 105
0
votes
2 answers

Setting `fileLengthLimit` of `AVAssetExportSession` causes: " Export failed: Cannot Open"

I am trying to limit the size of AVAssetExportSession to 10mb. Without setting fileLengthLimit, the "Export is completed". After setting fileLengthLimit = 10*1024*1024, the "Export failed: Cannot Open". - (void) splitVideo{ AVURLAsset…
Peter
  • 1,053
  • 13
  • 29
0
votes
1 answer

Export video with custom CMTimeRange issue

I guess i'm missing something. I have a slider which changes the asset duration, and the start time as well. If i'm exporting the video with the full duration, as let timeRange = originalVideoTrack.timeRange do { try…
Roi Mulia
  • 5,626
  • 11
  • 54
  • 105
0
votes
1 answer

AVMutableVideoComposition sometimes won't play video

I'm using this short snippet to set up my video. For some unknown reason - sometimes the video simply won't show up, while for other video it'll work perfectly. let videoTrack: AVAssetTrack = asset.tracksWithMediaType(AVMediaTypeVideo)[0] …
Roi Mulia
  • 5,626
  • 11
  • 54
  • 105
0
votes
1 answer

objective c - AvAssetReader and Writer to overlay video

I am trying to overlay a recorded video with AvAssetReader and AvAssetWriter with some images. Following this tutorial, I am able to copy a video (and audio) into a new file. Now my objective is to overlay some of the initial video frames with some…
0
votes
1 answer

AVAsset in Swift2

if let url = song.valueForProperty(MPMediaItemPropertyAssetURL) as? NSURL { audioAsset = (AVAsset.assetWithURL(url)) Some error in Xcode7 using AVAsset. The error says: 'assetWithURL' is unavailable: use object construction…
SoTm
  • 807
  • 1
  • 7
  • 10