Split a video with FFMPEG

Splitting video’s can be really useful, e.g, when multiple subjects have been talked about during a recorded meeting. Recently I had just this use case when we did a Techtalk in Google Meets with 2 subjects. We used the built in recorder from Google to get a nice mp4 file.

For archive reasons it might be better to split this video in 2 where each video contains a subject of the meet. The fastest way to edit any type of video is of course using ffmpeg.

We can use the ffmpeg binaries from our CLI with a given start and end time to split a video.

ffmpeg -ss 00:00:00 -i Techtalk_Recording.mp4 -to 00:46:20 -c copy TechTalkPhpStorm.mp4

This will copy a new video from the original Techtalk_Recording.mp4 to TechTalkPhpStorm.mp4 which starts at the beginning and ends the video at 00:46:20. Perfect!

The second subject of the tech talk was extracted the same way:

ffmpeg -ss 00:46:35 -i Techtalk_Recording.mp4 -to 01:18:52 -c copy TechTalkAccessibility.mp4

Now we have 2 files with both just our subject. Thanks to this stack overflow thread we use the -c copy method to make sure our splits will be created really fast :).

Using NodeJS through docker as CLI

Sometimes you want to build or run a simple NodeJS or PHP script. But if your current OS doesn’t have Node, NPM, or Yarn installed it might be a hassle to install this. But if you have docker available you can run the node container as a CLI. Just add the docker run command as an alias to your host and use yarn or node as if it was living on your host itself.

alias yarn='docker run --rm -ti -v ${PWD}:/app -w="/app" node:lts-alpine yarn'
alias node='docker run --rm -ti -v ${PWD}:/app -w="/app "node:lts-alpine node'

We mount the current directory (${PWD}) to the /app directory in the container and make sure we remove (--rm) the container after running the commands.

By giving the -ti flag we make sure then when we can interact with the shell when needed, i.e. when running yarn init