Python - Merge AAF/XML/EDL and Reference Video

In my studio we have offline editors that send me an AAF/XML/EDL and a reference video of their offline edit. My first step for all of these jobs is to load the AAF/XML/EDL and marry it to the reference video.

So this is my first attempt to automate with python. I’m looking for feedback and trying to cover all my bases for things that might pop up in this process.

Here is a quick overview:

  • import the AAF/XML/EDL to a sequence reel

  • import the reference video to the same sequence reel.

  • the reference video must be named the same as the AAF/EDL/XML with “_ref” added to the end.

  • the reference video needs to have the same start frame as the AAF/XML/EDL. e.g. don’t have the AAF/XML/EDL start on the first frame of picture and the reference video have a 2-pop.

  • Select the AAF/XML/EDL sequence and run the script. This will:
    — Create video version two.
    — Add tracks to this version equal to the original version.
    — Move all segments to version two.
    — Insert the reference video to version one.
    — Clean up empty tracks and lock the reference video / audio.
    — Make v2 the primary track and v1 the secondary.
    — Delete the reference video in the sequence reel.

  • This script uses flame.execute_shortcut(). The shortcuts used in the script should already have a shortcut entry. You will only be affected if you have deleted the shortcut keys for: ‘Overwrite Edit’ and ‘Swap Selected’.

Things still to do:
– add 1 second of virtual black to the heads and tails
– Automate the clean-up of the AAF/XML/EDL name (remove “_online” “_export” etc.)
– After all the merging, move the playhead to the top layer and first frame.
– Account for different names of reference videos? Needs some part of the name to be in common with the EDL.

If this is something you do on a daily basis… let me know what else you might be doing over and over that can be automated. (4.1 KB)


Nice. might be good to add all the transitions onto the ref clip too

For adding your virtual black, you may want to take a look at the padding_start and padding_end attributes of the PySequence to insure the presence of gaps. Followed by the set_gap_colour on the PySegment to convert the gap into a colour source. Both were added in Flame2023.1 Update.


Thanks Phillippe - Is there a way to move the playhead? Mostly to get it to the top track and first frame of the sequence.

1 Like

Going to test this out. Thanks BB!

The clip.primary_track should already move the playhead to the specified track.
To move the positionner in time, you can use clip.current_time.

1 Like

ha’ I was thinking of that yesterday! niceee

python pooower!

Hey @bryanb
Thanks for sharing this, it’s great!

Unfortunately, I wasn’t able to get “Swap Selected” to work even though I haven’t deleted the hotkey shortcut, and I wasn’t able to get multiple versions to work well so I made some tweaks. Instead of using “Swap Selected,” I’m using “Nudge 1 Track Up” and “Nudge 1 Track down.” I saw your note about not having access to patch controls, and yeah that seems like it would help a lot here.

I also used Phillippe’s suggestions to add black frames and more the playhead to frame 1. Here’s my version incase there’s something useful for you. (5.0 KB)

Thanks again!

Thanks John - I have found that Swap Selected can be finicky. Sometimes it doesn’t do it?

I didn’t know about Nudge 1 Track and that does seem smarter.