If you’re like me and have zero video editing experience and primarily work on Linux, learning open source video editing tools can be frustrating. I’m slowly learning blender for this purpose, but recently I’ve been taking to just using the CLI to manage most of my video editing needs. I’m not doing anything super visually important and sticking with basic operations, so the CLI works just fine for me. Plus all of these commands are automate-able.

I’ve included some examples of basic operations below. All you need to install is ffmpeg.

Cutting long videos into smaller clips

Cut long_video.mkv into smaller_clip.mkv from start timestamp 01:07:11 to end timestamp 01:08:13:

ffmpeg -ss 01:07:11 -to 01:08:13 -i long_video.mkv -c copy smaller_clip.mkv

Concatenating multiple videos together

ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mkv

This will read from the mylist.txt for what files to copy in which order. mylist.txt requires the format:

file 'clip1.mkv'
file 'clip2.mkv'
file 'funny_video.mkv'

If you don’t care about specific ordering, or if you’re deterministic enough to label your clips in numerical fashion, you can automatically create this list using a bash script like so:

set -eux
if [[ -f "${file_list}" ]]; then
  rm "${file_list}"

for fname in *.mkv; do
  echo "file '${fname}'" >> "${file_list}"

Combining directory of photos into a timelapse

Things like GoPros can automatically combine their photos into timelapses, but I often find myself over-sampling photos and wanting to re-adjust the time range, fps, or duration of the timelapse video. If you shoot timelapses on an interval timer, ffmpeg gives us most the tunables:

ffmpeg -r 30 -pattern_type glob -i "*.JPG" -s 1920x1440 -vcodec libx264 output.mp4

Note that the -s flag scales the images used. My camera shoots in some 6240x4160 but I downscale the images to 4k. Assuming your camera tags files with the appropriate metadata, file can show you information about the image, including its resolution.

▶ file DSCF0062.JPG
DSCF0062.JPG: JPEG image data, Exif standard: [TIFF image data, little-endian, direntries=13, manufacturer=FUJIFILM, model=X-T4, orientation=upper-right, xresolution=186, yresolution=194, resolutionunit=2, software=Digital Camera X-T4 Ver1.20, datetime=2021:08:23 16:53:52], baseline, precision 8, 6240x4160, components 3