Joining Camera Video Files

I have a Panasonic Lumix FZ1000, bought recently, but a 2015 design.
I love the 16x optical zoom Leica lens, all the SLR-like controls, and it captures 4K (3840 x 2160 pixels) video!

But — like many cameras — it insists on splitting a video recording into roughly 4Gb chunks. This made sense in an era when many personal computer file systems — and flash drives — had 4Gb file size limits. But while that era has passed, Panasonic hasn’t provided a setting to turn off this file-splitting feature. [7/4/2020: Nor has DJI in their latest Mavic Air 2 drone!]

Just yesterday I took a canal cruise in Amsterdam, and I ended up with three separate video files for my single video capture.

Here is the step-by-step process for using ffmpeg on Windows 10 to join the files back together. [If you can find a faster/easier method, please do share!]

NOTE: This works for .MP4 and .MOV files for sure, likely other video file extensions as well.

Step 1: Put Windows ffmpeg on your computer

I created the directory c:\data\ffmpeg. The ffmpeg.exe file, video files, and text files to perform the join will all go here (having all the files in one directory removes the need to specify directory/file paths).

Next I went to http://www.ffmpeg.org, clicked on Download, then on the Windows icon (under Get the packages), then clicked on Windows “builds”, and then I’m on a page (currently ffmpeg.zeranoe.com/builds/, but of course that could change), which shows Version “20170904-6cadbb1”, Architecture “64-bit”, and Linking “Static”.

There is a “Download FFmpeg” button (white text on blue background), and hovering over that shows it will download “https://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-20170904-6cadbb1-win64-static.zip”

So I downloaded that file (46.4Mb) to my computer.

Next, (using Chrome web browser) I “Show in Folder” to see the zip file in Windows Explorer.
Open the Zip file, and see a folder with the same name.
Open that folder, and see “bin”, “doc”, “licenses”, etc.
Open the “bin” directory, and see ffmpeg.exe, ffplay.exe, and ffprobe.exe.

Copy ffmpeg.exe to c:\data\ffmpeg.

NOTE: You can safely ignore the other files in the ZIP archive.

Step 2: Move your video files to this directory

Move or copy your video files to c:\data\ffmpeg.
These were my files:

P1000306.MP4
P1000307.MP4
P1000308.MP4

Step 3: Create the concat.txt and combine.cmd

combine.cmd is the batch file that will run ffmpeg with the correct parameters.
concat.txt is the input script for ffmpeg that lists the files to be concatenated.

Use Windows Notepad to create these two files, with contents as shown below from a CMD.exe prompt:

C:\data\ffmpeg>type concat.txt
file 'P1000306.MP4'
file 'P1000307.MP4'
file 'P1000308.MP4'
C:\data\ffmpeg>type combine.cmd
ffmpeg -f concat -i concat.txt -c copy output.mp4

Step 4: Are you ready to join your videos?

C:\data\ffmpeg>dir
 Volume in drive C is OS
 Volume Serial Number is xxxx-xxxx

 Directory of C:\data\ffmpeg

09/05/2017 07:41 AM    [DIR]          . 
09/05/2017 07:41 AM    [DIR]          .. 
09/05/2017 07:35 AM                53 combine.cmd 
09/05/2017 07:35 AM                65 concat.txt 
09/05/2017 07:39 AM        41,060,352 ffmpeg.exe 
09/04/2017 12:00 PM     4,269,672,793 P1000306.MP4 
09/04/2017 12:06 PM     4,268,239,859 P1000307.MP4 
09/04/2017 12:12 PM     3,473,859,545 P1000308.MP4

Step 5: Run combine.cmd to join your files

In your CMD.exe window, run the combine batch file.
You’ll get a lot of scary UNIX-like output, including some messages that appear to be errors!
[NOTE: I colored the text output just as it appears on my Windows 10 system.]

After ffmpeg finishes, the file output.mp4 will be a single video that is the joined version of your input video files!

I encourage you to rename output.mp4 to suggest the source file names, for example P1000306-8_joined.MP4.

C:\data\ffmpeg>combine

C:\data\ffmpeg>ffmpeg -f concat -i concat.txt -c copy output.mp4
ffmpeg version N-87196-g6cadbb1 Copyright (c) 2000-2017 the FFmpeg developers
 built with gcc 7.1.0 (GCC)
 configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-zlib
 libavutil 55. 74.100 / 55. 74.100
 libavcodec 57.105.100 / 57.105.100
 libavformat 57. 81.100 / 57. 81.100
 libavdevice 57. 8.100 / 57. 8.100
 libavfilter 6.101.100 / 6.101.100
 libswscale 4. 7.103 / 4. 7.103
 libswresample 2. 8.100 / 2. 8.100
 libpostproc 54. 6.100 / 54. 6.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000000efbbc0] decoding for stream 0 failed
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000000efbbc0] Auto-inserting h264_mp4toannexb bitstream filter
Input #0, concat, from 'concat.txt':
 Duration: N/A, start: 0.000000, bitrate: 95042 kb/s
 Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 3840x2160 [SAR 1:1 DAR 16:9], 94916 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
 Metadata:
 creation_time : 2017-09-04T12:00:02.000000Z
 Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 125 kb/s
 Metadata:
 creation_time : 2017-09-04T12:00:02.000000Z
[mp4 @ 0000000000f03340] track 1: codec frame size is not set
Output #0, mp4, to 'output.mp4':
 Metadata:
 encoder : Lavf57.81.100
 Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 3840x2160 [SAR 1:1 DAR 16:9], q=2-31, 94916 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 90k tbc
 Metadata:
 creation_time : 2017-09-04T12:00:02.000000Z
 Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 125 kb/s
 Metadata:
 creation_time : 2017-09-04T12:00:02.000000Z
Stream mapping:
 Stream #0:0 -> #0:0 (copy)
 Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000000034de840] Auto-inserting h264_mp4toannexb bitstream filter8x
[mov,mp4,m4a,3gp,3g2,mj2 @ 000000000321c620] Auto-inserting h264_mp4toannexb bitstream filter3x
frame=30600 fps=1004 q=-1.0 Lsize=11731316kB time=00:17:00.94 bitrate=94131.1kbits/s speed=33.5x
video:11714153kB audio:15626kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.013104%

foo foo

Results

So here are the files I have after combine.cmd completes.
[NOTE: The sum of the sizes of the three input videos is 12,011,772,197, which is 1,095,671 bytes smaller than the size of output.mp4. I don’t know why.]

C:\data\ffmpeg>dir
 Volume in drive C is OS
 Volume Serial Number is xxxx-xxxx

 Directory of C:\data\ffmpeg

09/05/2017 07:41 AM    [DIR]          . 
09/05/2017 07:41 AM    [DIR]          .. 
09/05/2017 07:35 AM                53 combine.cmd 
09/05/2017 07:35 AM                65 concat.txt 
09/05/2017 07:39 AM        41,060,352 ffmpeg.exe 
09/05/2017 07:41 AM    12,012,867,868 output.mp4 
09/04/2017 12:00 PM     4,269,672,793 P1000306.MP4 
09/04/2017 12:06 PM     4,268,239,859 P1000307.MP4 
09/04/2017 12:12 PM     3,473,859,545 P1000308.MP4 
              7 File(s) 36,077,589,732 bytes 
              2 Dir(s) 831,571,464,192 bytes free

Author: benslivka

19 start-ups, software, hardware, biotech, space launch, neurodiversity, learning, free markets, food, wine, cycling, walking, Seattle, Microsoft, Northwestern University, Garfield HS, DreamBox Learning, IBM, Amazon.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s