Linux: Command line video editing

By | May 12, 2019

The best way to do simple video in Linux is using the command line. This way you can do quick one liner commands that do the job fast and clean.

My favourite tool is ffmpeg.

Install ffmpeg:

If you do not have it already installed to install ffmpeg simply do (in Fedora):

Install the rpmfusion repo:

dnf -y install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
dnf -y install https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
Then install it:

dnf install ffmpeg

The following are several operations you can do.

Sub-sample a high frame rate video.
By default my GoPro is set to film at 720p and 60fps. This is great for dash camera setup (I mainly use the camera for that) but the disadvantage is that the video files are huge. To be able to post sequences a sub-sampling is necessary.

To sub-sample the video file execute the following:


ffmpeg -i GOPR4406.MP4 -r 25 file0.mp4

where:
-r 25 = specifies the sub-sampled framerate to be 25fps
-i GOPR4406.MP4 = the input file
file0.mp4 = the output file

Concatenate several video files with the same encoding
It is important for the files to be concatenated to have the same encoding. If not a conversion as described in the previous step can be done.

Create a text file mySet.txt with the following content:


file file0.mp4
file file1.mp4
file file2.mp4
file file3.mp4

Note that the files will be concatenated in the order they are listed.

Then execute the following:


ffmpeg -f concat -safe 0 -i mySet.txt -c copy final.mp4

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.