Copy GoPro Streams to MP4 with FFmpeg 7.1 on macOS
If you have ever used a GoPro camera, you probably know that it records videos in the MP4 format but stores additional metadata streams, such as GPS data, in the MOV format. However, sometimes you might need to copy these metadata streams from the MOV format to the MP4 format. In this article, we will show you how to compress MP4 files produced by GoPro while preserving the metadata streams using FFmpeg 7.1 on macOS.
What is FFmpeg?
FFmpeg is a free and open-source software project consisting of a vast software suite of libraries and programs for handling video, audio, and other multimedia files and streams. It is highly flexible and compatible with a wide range of file formats and codecs, making it an ideal tool for manipulating and converting multimedia files.
Downloading and Installing FFmpeg 7.1 on macOS
FFmpeg releases new versions regularly, and you can download the latest version of FFmpeg for macOS from the official website at https://ffmpeg.org/download.html. At the time of writing, the latest version is FFmpeg 4.4, but this article focuses on using FFmpeg 7.1. To download FFmpeg 7.1 on macOS, you can use a third-party package manager like Homebrew.
$ brew install [email protected]
Once you have installed FFmpeg 7.1, you can verify the installation by running the following command:
$ ffmpeg -version
This command should output the FFmpeg version, along with other information, including the operating system.
Copying Metadata Streams from MOV to MP4
To copy metadata streams from a MOV file to an MP4 file using FFmpeg 7.1 on macOS, you can use the following command:
$ ffmpeg -i input.mov -c copy -map 0:v:0 -map 0:a:0 -map 0:s:0 output.mp4
Here, input.mov is the name of the MOV file containing the metadata streams, and output.mp4 is the name of the MP4 file where you want to copy the metadata streams. The -c copy flag tells FFmpeg to copy the data from the input file to the output file without re-encoding the video or audio data. The -map flag specifies the streams you want to copy from the input file to the output file. In this case, the first -map flag copies the video stream from the input file, the second -map flag copies the audio stream from the input file, and the third -map flag copies the metadata stream from the input file.
If you want to compress the MP4 file while copying the metadata streams from the MOV file, you can use the following command:
$ ffmpeg -i input.mov -c:v libx264 -crf 23 -c:a aac -b:a 128k -c:s copy output.mp4
Here, -c:v libx264 specifies the H.264 video codec, -crf 23 sets the Constant Rate Factor (CRF) to 23, which is a tradeoff between the video quality and the file size, -c:a aac specifies the Advanced Audio Codec (AAC) audio codec, and -b:a 128k sets the audio bitrate to 128 kbps. The last -c:s copy flag copies the metadata stream from the input file.
Preserving GPS Data
One of the most crucial metadata streams that you might want to preserve while converting MOV files to MP4 files is the GPS data. GoPro cameras record a lot of GPS data, including the location, altitude, speed, and direction. However, not all MP4 files support GPS data. Therefore, you need to make sure that you are converting the MOV file to an MP4 file format that supports GPS data.
To preserve GPS data while converting MOV files to MP4 files, you can use the gpmd codec to encode the GPS data in the MP4 file. You can use the following command to encode the GPS data in the MP4 file:
$ ffmpeg -i input.mov -c:v libx264 -crf 23 -c:a aac -b:a 128k -c:s gpmd -map 0:s:0 output.mp4
Here, -c:s gpmd specifies the GPS data codec for the metadata stream. The -map 0:s:0 flag copies the metadata stream from the input file to the output file.
In this article, we have shown you how to copy metadata streams, such as GPS data, from a MOV file to an MP4 file using FFmpeg 7.1 on macOS. You have learned how to compress MP4 files while preserving the metadata streams and how to encode GPS data in the MP4 file. With this knowledge, you can easily convert your GoPro videos to MP4 files while preserving all the essential metadata streams.