Mp4 Export

Hey there Deepak,

A few months ago I asked the same question you’ve asked with my coworker @Josh_Laurence and with the immeasurable help of @ManChicken we discovered that the answer is indeed yes.

The reason I haven’t really published my findings to the community at large is because there are a few caveats and “holes” that I haven’t quite figured out, but we’re currently using it to wonderful success every day here at Assembly. Big caveat- this is for Rocky Linux. I would think it works with a few adjustments for Mac. mostly the ffmpeg part, but my guide here is not for Mac because I am not on a Mac.

The way this works is by exporting an .mov H264 from Flame from a carefully configured “Profile” file that makes a nicely compressed .mov H264 via a .cdxprof file. I say nicely because the default profiles that come shipped with Flame I found do not create H264s that are both “main” and “cbr” which is where I would lean if I were making these files using other means (Media Encoder for example). I made 3 for 3 different commonly used bitrates. They are zipped up in this zip here:

MP4_cdxprof.zip (2.6 KB)

They should be loaded to this location:

/opt/Autodesk/mediaconverter/2023.1/profiles/Quicktime/video/H264/

Then, load these 3 Export Preset .xml files to this location:

MP4_H264_5mbps.xml (1.8 KB)
MP4_H264_10mbps.xml (1.8 KB)
MP4_H264_20mbps.xml (1.8 KB)

/opt/Autodesk/shared/export/presets/movie_file/

These .xml presets were created in Flame and use the above profiles to create a .mov h264. You can create your own, you just have to ensure you adjust the python script we’ll be getting to in a moment.

Now you load the python hook to the python location:

/opt/Autodesk/shared/python

remux-to-mp4.py (2.0 KB)

This is the brilliant work of Bob Maple who did all of the heavy lifting on python to make this a reality. This hook looks to see if you have used the above mentioned .xml Export Presets, and if so, it uses ffmpeg to re-encode the .mov h264 into an .mp4 h264 and then deletes the .mov to clean things up. I toyed with the idea of circumventing ffmpeg and simply renaming the .mov to .mp4, but you run several metadata related risks if your delivery requires .mp4’s. The video codec portion passes through; however, the bug we could not solve is that we must re-encode the audio. When we didn’t re-encode the audio with ffmpeg, we found the audio would go out of sync. This is the part of the workflow that if someone else can figure out why and how to avoid this, I would love to not have to re-encode the audio. But for now, this is a necessary evil that I have come to terms with, and I don’t think it’s all that bad.

Finally, confirm that ffmpeg is installed on your system by running this command:

man ffmpeg

If nothing happens, then install ffmpeg:

sudo dnf -y install https://download.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo yum-config-manager --enable powertools
sudo dnf install --nogpgcheck https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-8.noarch.rpm -y
sudo dnf install --nogpgcheck https://mirrors.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-8.noarch.rpm -y
sudo dnf install -y ffmpeg
sudo dnf -y install ffmpeg-devel
rpm -qi ffmpeg

Once all of that is done, whenever you use the shared preset “MP4_H264” to export something, the python hook will come into play and convert your .mov into an .mp4 automagically. As we talked about, the only pitfall right now is that we need to double encode the audio as .aac–Flame does it and then FFMPEG has to do it too. If you can live with that, then it seems to be working well for me.

And again, I ask the community–if you can figure out how to make this work without double encoding the audio, hat’s off to you. Until then, feel free to ask questions and I can probably answer them since I’ve spent a bit of time with all of this.

12 Likes