Editing your video on the command-line
There are good video editors for Linux but every time I find myself in need of editing a video I end up spending more time learning how to use the program than benefiting from it.
Behind the scenes they use ffmpeg. Learning how to use ffmpeg is a much more transferable skill, for example if you want to write a service which encodes GIFs to videos or a service to crop images.
At our most recent hackathon I ended up editing the whole presentation video on the command-line using ffmpeg. These are some of the commands I used:
Trimming the beginning
A recording will often contain parts in the beginning that need to be removed:
Trimming the end
The same is true for the end of the material:
Both, -ss
and -t
, can also be combined into one command.
Background Music
For a background music track the volume had to be lowered:
There were also multiple audio tracks which had to be combined into one:
Several attempts to merge the background audio track failed due to the length of the audio track not matching the length of the video. This can be solved by generating a silent audio track and concatenating it to the end of the audio track:
Finally, to merge the audio track into the video track:
Scaling a video
One of the video files could not be concatenated with the existing video file because its resolution was smaller than the recorded material:
Concatenate videos
Concatenating videos is not always as easy as concatenating audio tracks. One way is to use the concat video filter:
These commands were sufficient to do all of the video editing needed. There are a lot of approaches to most of these commands and depending on the existing encodings or formats more complex parameters might be necessary.
To me this was greatly useful to have one more task where I can stay on the terminal (if you exclude all the research I had to do to find the commands).