Sunday, November 25, 2018

Combining mp4 Files Without Re-encoding Using FFmpeg on Windows Subsystem for Linux

I recently used FFmpeg installed on the Windows Subsystem for Linux on my Windows 10 machine to combine some mp4 video files without re-encoding the files. Being able to do this without re-encoding makes the process much quicker and does not result in image degradation.

Install the Windows Subsystem for Linux

If it is not already installed, you will need to install the Windows Subsystem for Linux. Instructions for doing this can be found at https://docs.microsoft.com/en-us/windows/wsl/install-win10. I have the Ubuntu distro installed (https://www.microsoft.com/en-us/p/ubuntu/9nblggh4msv6).

Install FFmpeg

To install FFmpeg (https://ffmpeg.org/) on Ubuntu open the Ubuntu command line and enter the following:
sudo apt install ffmpeg

Create Merge File

Using the text editor of your choice, create a text file that contains the list of mp4 files you want to combine. For this example I called the file input.txt. The format of this file is as follows:
file 'part1.mp4'
file 'part2.mp4'

Combine mp4 Files

The following command can be used to merge the files listed in the text file from the step above into a single mp4 output file without re-encoding the files:
ffmpeg -f concat -i input.txt -c copy output.mp4
The name of the new mp4 file in the example above is output.mp4.

No comments: