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.

Saturday, November 10, 2018

Trimming 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 trim the beginning and ending off of 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

Trim the Beginning of a Video

The following command can be used to trim the first 30 seconds off the front of an mp4 file:
ffmpeg -ss 00:00:30 -i input.mp4 -c copy output.mp4

Trim the Ending of a Video

The following command can be used to trim an mp4 file at a specified position. In this example it copies the first thirty seconds of the input.mp4 file and copies it to the output.mp4 file.
ffmpeg -i input.mp4 -c copy -to 00:00:30 output.mp4
Another way to accomplish this is to specify a duration. In this example it copies the first fifteen seconds of the input.mp4 file and copies it to the output.mp4 file.
ffmpeg -i input.mp4 -c copy -t 00:00:15 output.mp4

Trim the Beginning and Ending of a Video

The following command can be used to trim the first 30 seconds off the front of an mp4 file and then copy the next three minutes and forty five seconds. The resulting file will be three minutes and forty five seconds long:
ffmpeg -ss 00:00:30 -i input.mp4 -c copy -t 00:03:45 output.mp4