Learning AVFoundation — Part 1 (Introduction)

Divya Nayak
2 min readDec 5, 2019

--

Learning the AVFoundation framework is a dream of all most every iOS developer 😜. Many a time I have opened the Apple documentation to fulfill my dream which didn't seem much easy as I have ended up with many questions to proceed. Here I am to put it easier (I am trying 😉…) for those who also want to fulfill their wishes of learning the AVFoundation kit.

AVFoundation is a framework to play around the time-based audiovisual media(ex: audio, video). Using this we can create audiovisual media, edit media, generate thumbnails, reencode these files. To perform the minimal task like to play videos, to capture videos we have higher-level frameworks for which we don't need to go deeper into AVFoundation Kit.

AVFoundation uses some of the data structures/opaque objects that give certain details related to audio and video from Core Audio and Core Media frameworks. It also uses the Core Animation framework to represent the video and presentation layer hierarchy. This can be understood in detail in the later parts of the blog.

AVFoundation is a framework to play around with media. So this media is represented as AVAsset.

When we say a media (audio/video) it will have duration, title, audio/video tracks, rate at which media has to be played and so on. All these details are represented as AVAsset class. AVAsset is a superclass. It has derived classes which are used to create an AVAsset object. Like we can create AVAsset using a URL or we can create AVAsset using compositions (i.e, using multiple tracks/media, editing, adding/removing tracks, etc and exporting them into a media file).

A media data contains pieces of an individual uniform type of data on a time basis and it is called a Track. A simple video asset has one audio track and one video track. A complex video asset can have multiple audio and video tracks overlapping each other. Hence an AVAsset holds the array of tracks (a track is represented as AVAssetTrack) contained in the media.

Knowing this, we can learn more about playing media, generating thumbnails, reading, writing and reencoding the assets, editing assets, capturing media in the upcoming parts of the blog.

Continued: Part 2 https://medium.com/@divya.nayak/learning-avfoundation-part2-understanding-and-using-avassets-ef70e64d7ade

Thank you!

--

--