Working with AAF and OpenTimelineIO - AcademySoftwareFoundation/OpenTimelineIO GitHub Wiki

Working with AAF and OpenTimelineIO

When working with OTIO and AAF together there are quite a few details that must align for smooth interoperation. This guide will attempt to show you how to do some common operations, such as converting between OTIO and AAF, relinking media, etc.

AAF is well supported by several applications in the video and audio editing industry. Avid Media Composer & Pro Tools, Adobe Premiere, DaVinci Resolve, and several others support AAF. If you are looking for rich interchange, including media transfer between applications that already support AAF, then using AAF for that purpose is a great choice.

If you are working with a mixture of applications where some support AAF and others do not, or you want to just get essential playlist information from an AAF without getting into the details, then OTIO can help you build a pipeline to pass timelines and metadata through your workflow.

AAF to OTIO

Let's take, for example, a timeline originating in Avid Media Composer. Say we have a music video with a few dozen video and audio clips, and a bunch of effects. Our visual effects team wants to review their latest renders in the context of your latest editorial cut, and at the same time, your producer wants a list of all the media being used, to ensure that their time/cost estimates are on target.

First, we open the latest cut of our music video in Avid Media Composer

[insert Media Composer screenshot here (timeline + record monitor)]

Next we export a composition AAF to disk.

[insert AAF export settings dialog screenshot here]

Next, we convert that AAF into an OTIO using the command line tool otioconvert like this:

% otioconvert -i music_video_v10.aaf -o music_video_v10.otio

We can view the result in otioview for a quick visual validation.

% otioview music_video_v10.otio

[insert screenshot of otioview here]

We can also look at some statistics about the running time, number of clips, etc. via otiostat.

% otiostat music_video_v10.otio
[insert otiostat output here]

This OTIO file can be handed off to the visual effects team, and your producer for their uses.

VFX Conform

If you are using Hiero, Nuke Studio, or other industry tools, you may be able to import OTIO, or another format that otioconvert can produce, in order to do your conform in those tools. For the purposes of this tutorial, we will accomplish this task with some light Python scripting.

Let's start with some sample code included with OTIO. We will download this, modify it, and make our own script.

% python conform.py

In this example, lets say we have new video clips in a folder, but the names don't match exactly, since ours are newer renders. Luckily the prefix of the filenames do match, so we can use that. In a real production example, you might have an asset management system to query, or other modules to help find new versions of your clips, but for this example, lets keep things simple by looking at just local files.

[insert steps for fuzzy name matching]

Now we want to view our resulting timeline with the updated media.

If you have RV, you can use otioconvert to produce an RV session file.

% otioconvert -i vfx_conform.otio -o vfx_conform.rv

[insert example using gstreamer? what else can easily play an OTIO?]

Media Inventory

[insert example of using otiotool to list the media used in an OTIO]

OTIO to AAF

Now lets take our conformed timeline back into Avid Media Composer. We need to get the new video clips, and our updated timeline into Media Composer in two steps.

OTIO doesn't handle the media portion of this, so lets assume that you've already imported the new video clips into Media Composer. Some pipelines might pre-convert clips to MXF, AAF, etc. but Media Composer is happy to transcode or link media in a variety of ways.

OTIO can convert your updated timeline into a composition AAF via otioconvert but we need to take care that the media links up correctly. AAF uses a unique identifier called a "MobID" or "SourceID" to link a clip to a specific media object "mob". By default the OTIO AAF adapter will use three strategies for finding the right MobID to link to:

  • Clip metadata
  • Media Reference metadata
  • Linked AAF file

When we first converted an AAF to OTIO, you may have noticed a bunch of AAF-specific metadata on each clip and media reference.

[insert example AAF metadata here]

The OTIO AAF writer will look for that same metadata as a hint about which MobIDs to link to. It looks for these in particular:

  • clip.metadata.get('AAF',{}).get('SourceID')
  • `clip.media_reference.get('AAF',{}).get('MobID')
  • `clip.media_reference.get('AAF',{}).get('SourceID')

If none of those are found, then it will look at the clip.media_reference.target_url to see if it points to an AAF file, and then extract the MobID from that (assuming it is a single video clip in that AAF).

There are also some options you can pass to otioconvert or to otio.adapters.write_to_file() if you want to control this. The options are:

  • prefer_file_mob_id=True = first look for a linked AAF file, before looking at metadata.
  • use_empty_mob_ids=True = if no MobID is found, then generate new ones.

If you choose use_empty_mob_ids=True then clips assigned new MobIDs will be offline, and need to be relinked within Media Composer. In that case, you can use the "Relink..." feature in Media Composer to relink to media based on clip name, Tape & Timecode, or other metadata.

Getting back to our example, lets run this:

% otioconvert -i new_vfx.otio -o new_vfx.aaf

This fails with the message: [insert error message here] So lets assign new MobIDs to the new clips.

% otioconvert -i new_vfx.otio -o new_vfx.aaf -A use_empty_mob_ids=True

Now we can import this into Avid Media Composer and see the result.

[insert screenshot with mixed online/offline clips]

[insert instructions for Relink... here]

Learning more about AAF

[insert links to AMWA, AAF object model & edit protocol here]