Delving into Delusion

Converting mp4 to mov with FFmpeg in Ubuntu

 March 27, 2020      Stardate: 73701.6     Tagged as: Ubuntu FFmpeg

Update
Please see the post on how I turned this into a script that can be executed on a file by right-clicking.

GoPro outputs video in H.264 mp4 containers and the Hero6 and Hero7 now can output in the more efficient HVEC H.265 mp4 container. This is great because:

  1. nearly everything can read and play H.264 mp4 files
  2. since the H.265 mp4 is more space efficient you can save even more video to your memory card.

Yeah! But wait…. Not everything can read/play the new H.265 mp4.

FYI, here are some great posts by havecamerawilltravel that you should read:

My goal is to edit and color correct my home videos in Davinci Resolve 16 (DR16) but it turns out it doesn’t import these GoPro video files directly, at least not in the Linux free version.

In the support notes of DR16 it states that :

DR16 Input Codecs

Handbrake is a GUI front-end to ffpmeg and is awesome, I’m sure it could do it but I wanted something that I could run from a shell script and I wasn’t exactly sure what it was doing under the hood. My goal was to preserve the highest resolution and quality during the conversion or “transcode” to work with in DR16.

Installing FFmpeg on Ubuntu 20.04

This is pretty simple, as described in this tutorial instructions.

sudo apt install ffmpeg

Converting my Video from mp4 to mov

In my research and experimentation I found success in two codecs; Apple ProRes and Avid DNxHD. You can view all the installed and available codecs on your machine with ffmpeg -codecs. If you search through the long list you will see a bunch of H.264 decoders. I don’t know which ones are better or if they are, but I’ve seen these two used and recommended on the interwebs.

As I said, I tried both codecs and didn’t find any difference between the two. They both decoded high-res 4k video and converted AAC audio into PCM audio. I’ll tell you later why that’s important. The advantage of using ProRes is that the command line is a bit easier:

ffmpeg -i input.mp4 -c:v prores -profile:v 3 -c:a pcm_s16le output.mov

The advantage of using DNxHD is that you can specify all the nerdy details if you want to, but that’s a double edge sword because you can’t leave them out and still work. You must specify all the nerdy details.

Here is the final command, assuming 4k resolution at 23.967 (aka 24) fps.

ffmpeg -i input.mp4 \
    -c:v dnxhd \
    -profile:v dnxhr_hqx \
    -vf "scale=3840:2160,fps=24000/1001,format=yuv422p10le" \
    -b:v 110M \
    -c:a pcm_s16le \
    output.mov

Audio Transcoding

Referring back to the Black Magic Support Codecs, we see that mp3 and AAC are not supported in either free nor Studio Linux version. That sucks…So this is why we have to convert the audio when we convert the video.

DR16_InputAudio

FFmpeg Options/Arguments

Software Versions

This is an automated list of software versions used during the writing of this article.

SoftwareVersion
OS Ubuntu 20.04 LTS
FFmpeg4.2.2-1