Summary of AVFoundation Intro guide

Joon Won Lee
2 min readMay 29, 2018

--

Growth of media business

The hottest products these days are based on media business. And their growth are continuing right now.

Netflix and Amazon Prime continue growth with their ad-free experiences, and Hulu and YouTube are racing to launch their own subscription models.

Spotify has proven that people will pay for ad-free radio.

Not only those big tech companies jump into media business, many start-up also invest to media products.

Being a media programming expert developer

With media business growth, company need to hire developer who are good at media programming.

As an iOS Developer, I and my co-worker discussed about how can we be a media programming expert?

We shared lot’s of opinions to be an expert on media programming.

But one thing is clear which is we need to be familiar with avfoundation, anyway.

So, we looked into the AVFoundation Programming guide and summarized it.

Summary(Intro part)

Introduction

About AVFoundation

  • play, create time based audiovisual media

Framework architecture

For Simple Task

  • Play: use AVKit
  • Record Video: use UIImagePickerController

At a Glance

Two facets of API

  • Video
  • Audio

Representing and Using Media with AVFoundation

AVAsset

  • primary class for representing media
  • not tied to particular data format(like mp4, mp3, mov…etc)
  • individual media data is a uniform type(called Track)
  • It is just representing media(does not mean ready for use)

Playback

  • Separate presentation state(play, displaying..) from the asset itself
  • presentation state is managed by player item
  • play player item(eg. avplayeritem) using player(eg. avplayer )

Reading, Writing, and Recording Assets

  • Reencode: use Export Session, Asset Reader, Asset Writer
  • Visual representation of audio: use Asset Reader

Thumbnails

  • generate thumbnail: use AVAssetImageGenerator

Editing

  • create new assets:
  • use Compositions
  • you can also use sample buffer or asset writer
  • add, remove, reorder: use Mutable Compositions
  • A Composition reside in memory, you can export them as a file using export session

Still and Video Media Capture

  • Recording av data from device(cam, mic) is managed by Capture Session
  • Capture Session manages flow data from input(cam) to output(display)
  • Manage data flow !!

Concurrent Programming with AVFoundation

Callbacks from AVFoundation are invoked on which its internal tasks

2 guideline for notification and threading

  • UI related noti occur on main thread
  • class or method that require create a queue will return notification on the queue

Must See code

Prerequisites

--

--