Automate Video Editing with Python

Automate the editing of explainer videos to create shorts with text-to-speech comments for the training of warehouse operators

Automate Video Editing with Python

Article originally published on medium.

You are an operational manager in the logistics department of an international fashion retailer.

In order to support the onboarding of new operators and administrative staff you would like to prepare training videos.

Examples of training screens โ€” (Image by Author)

Your colleague has shared with you an explainer video (video by author) introducing all the processes of warehouse receiving.

To animate your sessions, you want to cut this video into short clips explaining each of the processes.

In this article, we explore a method to automate these simple video editing tasks using the python library Moviepy.

๐Ÿ’Œ New articles straight in your inbox for free: Newsletter

Problem Statement

Training Material

In this video, you have a complete presentation of several processes involved in the reception of products in a Warehouse.

Processes presented in the video โ€” (Video by Author: Supply Science)

Therefore, you would like to use this video that is listing the different processes as training support for your onboarding sessions:

  • Total Duration: 00:03:18
  • 18 sections including the intro and outro
  • Background music but no background voice


You want to cut the video, remove the background music and create shorts with audio comments.

Workflow in three steps โ€” (Image by Author)

The idea is to build an automated workflow using Python that will

  1. Load the original video
  2. Remove the background music
  3. Cut the video into several shots that focus on different processes
  4. Add audio comments generated with a Text-to-speech solution


There is a solution using the Python library Moviepy. For more details, I strongly suggest having a look at the documentation.

If you want also to automate graphic design, there is another tutorial for you


Step 1: Loading the video

We start by loading the .mp4 file of the original video that you can find on my Youtube Channel (Link).

Step 2: Cut the video

As you want to focus on some specific processes, you will not use the entire video.

Generate shorts by cutting at certain times โ€” (Image by Author)

Therefore, we need to find a method to cut the video at specific times to generate short clips that will be used to show a specific process.

Function: Convert to seconds

๐Ÿ’ก Insights
Weโ€™ll need this function later when weโ€™ll start to cut the video.

Action: Cut the video

๐Ÿ“น Result

๐Ÿ’ก Insights
You have a short video clip with the background music cut from the original video at the right timestamps.

Step 3: Remove the sound

You would like to play videos without sound, so you want to take your shorts and remove the sound.

๐Ÿ“น Result

๐Ÿ’ก Insights
You can also apply a fraction of the volume using .volumex(fraction) that can be lower than 1(reduction) or higher than 1 (increase)

Step 4: Combine two shorts

You have cut two videos and you would like to play them successively? There is a Moviepy function for this,

๐Ÿ“น Result

Step 5: Stack the videos

You would like to show several processes simultaneously? You can stack the videos on the same screen.

๐Ÿ“น Result

Stacked videos โ€” (Image by Author)

Step 6: Add some lag

If you want to stack the videos but with a lag of 5 seconds between each video, it can be done. (I have no idea why someone would do that, but why not!)

๐Ÿ“น Result

Stacked video with lag โ€” (Image by Author)

Final Step: Add Text-To-Speech Comments

We have generated comments using a Text-to-speech API. Can we add them to the video?

The answer is yes!

๐Ÿ“น Result

๐Ÿ’ก Insights
Google TTS (free tier) is very bad! Do you know a better one at a reasonable price?


For sure, we are far from Adobe Premiere or Final Cut Pro. But itโ€™s doing the job if you need simple edition tasks.

Moreover, I have shared with you only a fraction of what the library can do. I strongly suggest having a look at the documentation for more insights.

You are now ready to design training materials or start your fully automated Tiktok Channel.

I am sharing other video tutorials on automating manual tasks like PowerPoint, Graphic Design or Business Planning in a dedicated Youtube Channel,

About Me

Letโ€™s connect on Linkedin and Twitter, I am a Supply Chain Engineer that is using data analytics to improve logistics operations and reduce costs.