Export Avid Mixdowns straight into FFmpeg

Avid’s export capabilities have been rough around the edges, to say the least, for some time, especially when trying to use QuickTime to encode into a non-native codec such as H.264. But you can now perform a mixdown within Avid to your favourite native Avid codec, and then use FFmpeg to combine those renders directly into a single multiplexed file suitable for burning to DVD or web upload. You don’t need to export from Avid itself.

Here’s how.

First, mark an in and and out point in your Avid timeline, and perform two mixdowns one after the other; one for video, one for audio. For your video mixdown, use the codec that appears most often in your sequence, or the codec you used for most or all of your renders.

Internally, your mixdowns will have been saved by your Avid as MXF files. For a sequence with stereo audio, there will be three files: one for video, and two for the audio (being the left and right channels).

At this point, you can close your Avid application, or use it for something else. The processing that follows takes place separately from the Avid program.

Use Windows Explorer, or the Mac Finder, to locate the most recently modified files in your “Avid MediaFiles” folders. In this example case, this was shown to me:

top-of-avidmediafiles

The last three files, with similar filenames, are the video file and the two audio files that were created during the mixdown. FFmpeg will now encode and multiplex these three files to produce what you need.

If you’d like to perform something else useful on the audio at this point, e.g. making its level meet the EBU R.128 loudness specification, that’s easy. First, I measured the volume:

ffmpeg -i "\Avid Mediafiles\MXF\1\LECTURE 25i 11JUNE2558B15BD.mxf" -i "\Avid MediaFiles\MXF\1\LECTURE 25i 11J558B15BD.1.mxf" -filter_complex "[0:a][1:a]amerge=inputs=2,ebur128=peak=true:framelog=verbose[aout]" -map "[aout]" -f null NULL

…and out came the result:

[Parsed_ebur128_1 @ 0000000000c7c3c0] Summary:

Integrated loudness:
I: -17.1 LUFS
Threshold: -27.6 LUFS

Loudness range:
LRA: 4.9 LU
Threshold: -37.7 LUFS
LRA low: -20.5 LUFS
LRA high: -15.6 LUFS

True peak:
Peak: 2.3 dBFS

So the audio gain in dB required is:

-23 - (-17.1) = -5.9

Also, check the “True peak” value. If it hits 0dB, you’ve probably got some clipping and may want to revise your audio mix. In any case, your broadcaster will want the True Peak to be below a specified value after your volume has been adjusted. In the case above, there is indeed a spike that is reconstructed by FFmpeg’s interpolation algorithm, but which was brought into specification by the volume attenuation in the next step below.

Next, in my example, I issued a command line to do several things:

  1. combine both audio streams into a single stereo stream,
  2. adjust the audio gain,
  3. encode the stereo audio stream,
  4. post-process the video stream to clean it up, and resize it for YouTube’s 480p format,
  5. encode the video stream,
  6. add some useful metadata to show decoders how to behave,
  7. multiplex the encoded streams together.

The constant-rate-factor value (-crf option), which determines the encoding quality, is deliberately kept high because online services such as YouTube and Vimeo always recode.

Here is the whole command line I just used to create a standard-definition YouTube upload, with colour and video levels correctly encoded into the bitstream:

ffmpeg -i "\Avid MediaFiles\MXF\1\LECTURE 25i 11JUNE2558B037E.mxf" -i "\Avid Mediafiles\MXF\1\LECTURE 25i 11JUNE2558B15BD.mxf" -i "\Avid MediaFiles\MXF\1\LECTURE 25i 11J558B15BD.1.mxf" -filter_complex "[1:a][2:a]amerge=inputs=2,volume=-5.9dB[aout];[0:v]hqdn3d,scale=854:480,smartblur=1.0:-1.0,setdar=16/9[vout]" -map "[vout]" -map "[aout]" -acodec libfdk_aac -vbr 5 -vcodec libx264 -aspect 16:9 -crf 18 -x264opts fullrange=off:transfer=bt470bg:colorprim=bt470bg:colormatrix=bt470bg -metadata title="Elsewhere and Otherwise" -metadata artist="Peter Messer" LECTURE.mkv

With just two quick command lines, my Avid mixdowns are ready for YouTube upload without having to rely on any of Avid’s strange interaction with QuickTime during export. And the encoding is much faster than Avid can manage.

Leave a Reply

Your email address will not be published. Required fields are marked *