Edit your videos AUTOMATICALLY with this Python code! | by Favio Vázquez | Towards Data Science

The time has come! I’m creating courses for amazing companies like Business Science and Ciencia y Datos and I’m editing videos is a pain in the a**!! The software I’ll present you here is by the great Carykh.
The goal of the system is to edit the annoying silences in videos, the error we make, and almost every piece of something you’d like.
It won’t transform your video into a beautiful video, but at least it will allow you to save hours and hours of listening to yourself failing.
If you are not a video creator, but you consume videos on the internet this can help you watch them faster. I remember when I was studying and I watched a lot of Stanford and MIT videos, it took me hours and a lot of the time the professor wasn’t even speaking. So this can help with that too.
I tested the system on MatrixDS one of the best tools for launching a terminal and a Jupyter notebook for free and in seconds. So you can reproduce that there.
The first thing you need to do is to clone the repo:
github.com
git clone https://github.com/carykh/jumpcutter.git
Then install the requirements:
cd jumpcutterpip install --user -r requirements.txt
You’ll also need ffmpeg. If you are in Ubuntu:
sudo apt updatesudo apt install ffmpeg
If you are in MatrixDS you’ll need to be root so:
sudo suapt install ffmpeg
Now the fun part! I created a simple video to test this out. Here you can see the original video:
What I did in MatrixDS was upload the video in the same folder of the cloned repo. And then after running this command:
python3 jumpcutter.py --input_file auto_2.mp4 --sounded_speed 1 --silent_speed 999999 --frame_margin 2
I had my video edited in seconds. SECONDS!!
You can see the result here:
THIS IS JUST AWESOME :)
Right now there’s no much documentation about the software but the code is open source so you can go to the repo and see everything.
The basic command is
python jumpcutter.py --input_file path/to/file.mp4
You can play with this options:
optional arguments:  -h, --help            show this help message and exit  --input_file INPUT_FILE                        the video file you want modified  --url URL             A youtube url to download and process  --output_file OUTPUT_FILE                        the output file. (optional. if not included, it'll just modify the input file name)  --silent_threshold SILENT_THRESHOLD                        the volume amount that frames' audio needs to surpass to be consider "sounded". It ranges from 0 (silence) to 1 (max                        volume)  --sounded_speed SOUNDED_SPEED                        the speed that sounded (spoken) frames should be played at. Typically 1.  --silent_speed SILENT_SPEED                        the speed that silent frames should be played at. 999999 for jumpcutting.  --frame_margin FRAME_MARGIN                        some silent frames adjacent to sounded frames are included to provide context. How many frames on either the side of speech                        should be included? That's this variable.  --sample_rate SAMPLE_RATE                        sample rate of the input and output videos  --frame_rate FRAME_RATE                        frame rate of the input and output videos. optional... I try to find it out myself, but it doesn't always work.  --frame_quality FRAME_QUALITY                        quality of frames to be extracted from input video. 1 is highest, 31 is lowest, 3 is the default.
Yes! You can even pass a YouTube video link and it will download the original and also change the video creating a new one. For that the command will look like this:
python3 jumpcutter.py --url https://youtu.be/2MjlMpEzDA8 --sounded_speed 1 --silent_speed 999999 --frame_margin 2 --frame_rate 3
And that’s it.
Lovely work. Btw, the code are just 203 lines of code! The power of Python these days amazes me.
Thanks for reading this. If you have any questions please write me here:
www.linkedin.com
Have fun learning :)