Bash script for video slideshows

A command line video editor

The need for this little script written in bash was born out of a simple necessity: I wanted to publish some videos where I talk about stuff, but I found editing a video in a graphical video editor extremely tiring. All I needed was to put some pictures at specific timestamps, and instead found myself clicking and dragging stuff with the mouse, half of the time not getting the result I wanted.

How easy would it be to just stay in my favorite Text Editor (vim/neovim), write up some rules, like at time x show picture y, and then easily export it to a video? Well, I ended up writing a simple script which does exactly that, and in the following I will describe the journey towards it. Perhaps it will be of good help to you. A video editor from the command line/terminal sounds extremely difficult and nerdy, but I assure, for me personally it is so much simpler than any of those video editing programs like iMovie, Adobe Premiere or Final Cut Pro.

The groundwork for a command line video editor

FFMPEG is a truly amazing tool, absolutely unironically, whatever other people might jokingly convince you of (Interview with FFMPEG enthusiast). Together with Imagemagick it forms the perfect duo to manipulate photos and videos in a simple but powerful way. The only left to do is to write some logic around it. While you could choose some programming language like Python, I went with Bash, as it comes preinstalled with most UNIX Distro's. This way I could run it from my computer running either MacOS or Linux or using my phone via my server. The added advantage is that even on the go I could easily produce a video.

Bash Script Usage

The full script is quite short, you can find it on my Github page. The way it works is quite simple:

First you create an input text file, which looks like this:

00:00:12;|Some random text, which will be converted into a video
00:00:14;|More text, appearing two seconds after the previous one

On the left side you see a timestamp, in the format Hours:Minutes:Seconds. After this is a semicolon (;) and to the right of it comes either a filename or custom text. The timestamp depicts the time until the picture or text on the right will be shown. So in the example above, picture1.jpg will be shown from 0 until 4 seconds of the video. And to the right the file referenced by the filename has to be in the same working directory. You can even add some text, which has to start with a | character - it will automatically converted into a video.

The last thing you need is background audio, which can be either your voice narration of a text or a piece of music - that's your choice.

When you have all of this just run one single command:

ffmpegslider -a audiosource.mp3 -r 1920x1080 -i input.txt -o output-video.mp4

And then in the same working directory will appear the full finished video file (depicted by the -o flag).


By the way, if you want to add a facecam, and your audiosource is a video, this is supported as well! Just run the following command:

ffmpegslider -a audiosource.mp4 -r 1920x1080 -i input.txt -o output.mp4 -t facecam

For more usage and installation instructions as well as the commented source code see the Github page.

Vertical video

Also you can change the resolution (depicted by the -r flag) to be a horizontal as well as vertical aspect ratio. All the pictures will be resized automatically.


Again, it all sounds terribly complicated, but once it is set up even your grandma can create great slideshows. Feel free to build upon the script and add your own features. You can follow me on my social media because I have already uploaded videos created by this script.