THE POWER OF PYTHON AND FFMPEG - STORY 4 - H264
Once in a while I’ll receive video reference files for a series of shows in the H.264 format.
H.264, otherwise known as MPEG-4 Part 10 Advanced Video Coding (MPEG-4 AVC), is a very efficient video codec. It packs a very high quality looking picture into a very small file.
The issue I have is that H.264 video can be very processor intensive when decoding, especially if the video file also has AAC audio (which is also processor heavy to decode). This can lead to problems when doing heavy editorial and mixing sessions with many tracks in ProTools, especially when you need to make sure sound effects and dialogue are in sync to the frame. The video can begin to stutter and even crash. Fortunately for most of my work, this isn’t an issue as I’m really doing a light conform and QC without any scrubbing. Also, prior to using the H.264’s, I extract the audio as WAV files. I could also convert the video to Motion JPEG-A (or Apple JPEG-A) as well, but for what I’m doing, it’s not always worth the extra transcoding time to do that. I know that where I used to work, that’s exactly what we did; take client delivered h.264/AAC files and convert them to Motion JPEG-A with extracted WAV files. This ensured the video would be good in any ProTools session for any type of work, and it took the task of importing audio form the movie out of ProTools thus saving the editor a wee bit of time.
I’m all about saving a wee bit of time where I can, so I continue to extract the audio as WAVs at the same time as getting the commercial blacks (see THE POWER OF PYTHON AND FFMPEG - STORY 2). Now of course when dealing with just 2 track guide audio on a 30 min. show, it only saves about 30 seconds of time per episode (hey, that still adds up over 24 episodes!). The real savings are when I get a series of 1 hour shows that have 5.1 guide audio or a group of features with 5.1 audio. Importing 5.1 audio from video for a 2 hour feature can take minutes depending on your processor speeds.
FFMPEG is very powerful in the way it’s able to take a single input and map the various essences to different outputs with their own set of filters. So transcoding H.264 to MJPEG-A and the embedded AAC audio to WAV can be done in one command line. What I have done is added a line of FFMPEG code into my Commercial Black Python script giving me that separate WAV file. It took a bit of trial and error to determine what the AAC to WAV decoding delay was and compensate for that in the FFMPEG code so that the WAV file is now within 2 samples of the original AAC audio. It would appear this delay has changed over time with different iterations of the source FFMPEG code, so make sure to run some tests especially after updating your FFMPEG version to make sure your scripts are still good.