AutoMotion: How I Automated My Video Editing Process

theapache64 - Mar 12 '20 - - Dev Community

Hey DEV community! This is my first post, and I'm thrilled to share this with you!

The Dream

While streaming YouTube videos, I would often dream about becoming a YouTuber, as I'm sure many of us do. I feel like I have a wealth of knowledge I'd like to share with the world. Small tutorial videos, talking about how I develop my hobby projects, and providing developers some productivity tips. Just something, anything, even if on a small scale. But to do these things, πŸ™„ I'd have to:

  • Learn the fundamentals of video editing and how to use various editing software πŸ“”
  • Spend a good portion of time editing my video projects πŸ‘¨β€πŸ’»
  • Do the usual, and often repetitive, drop-crop-trim process βœ‚οΈ
  • Switch from Ubuntu, my primary OS that I love, as most of the professional video editing software works only on Windows/MacOS πŸ˜₯
  • Spend a lot of time waiting for the final output to render ⏳
  • And many other reasons to push me away from my dream πŸ™„

I know, I know. All these things make me sound like a really lazy person. That's because I AM! 😁 So what do I do?

Moment of Inspiration 🌩️

"I know some dumb programming. Would I be able to automate this process?" I asked myself, and that was it. What did I have to lose? So I decided to try and automate this process.

Research πŸ”

I've heard that ffmpeg is a good tool to process video frames. So I quickly browsed through the docs, and found that it's pretty straightforward even for a simpleton like me.

Core Feature πŸ€–

If the input video is a 10 minutes footage, and if it has 1 minute of non-talking area (the area where no one is talking) after every 2 minutes,

input

I want to timelapse those areas to 15 seconds of footage. So the total video length becomes 7 minutes and 45 seconds.

Also, while running the timelapse, I want to replace the footage's raw audio with some cool BGM πŸ₯.

So this was the core feature I wanted to implement in the thing, for which I had not decided a name at that point.

Initial Development βš—οΈ

I created a shell script to process a sample video I downloaded from YouTube. I wrote some basic stuff in it, like

  • Adding intro
  • Adding text to intro
  • Trimming video parts
  • Timelapse video parts
  • Adding background music
  • Adding watermark
  • Adding end credits

It took me 3 days to write it all by hand. I just wanted to check if ffmpeg has the potential to do what I want it to, and it really impressed me, going beyond my expectations.

Next thing I wanted to do was generate these ffmpeg commands dynamically. πŸ’£

Code Improvements ⌨️

It took me around 5 days to code the entire program. Then I proceeded to make some code improvements and made all possible input variables dynamic, which means you can control pretty much anything in it: Timelapse speed, intro title, watermark title, minimum timelapse duration, you name it.

Here's the overview of the core stack:

At this stage, I also settled on a name for this project, auto-motion.

Now, let's run it! πŸƒ

Input πŸ•Ή

Input is a 6 minutes video from comma archive, captured by George Hotz in a recent hackathon they conducted.

Execution πŸ–±οΈ

It only took ~1 minute to edit and render the output, whereas a manual edit would have taken hours, perhaps even days, to accomplish it. 🀷

Output πŸ“Ί

The output, reduced to 4 minutes 43 seconds, is here. It includes 7 time-lapses of different lengths.

I know the output is not as enjoyable as a manually edited one, but I believe I can improve this in due time πŸ˜‡. You'll see more dynamic and interesting output in the near future on my Youtube channel. If you like my work, please subscribe to be notified. πŸ€—

Download πŸ“©

You can view the source code as well as download the program from GitHub.

GitHub logo teamxenox / auto-motion

A tool to edit your lengthy screen records, automatically.

auto-motion

A CLI program to edit your videos, instantly, with minimum input.

Dependencies πŸ’’

Install πŸ› 

wget "https://raw.githubusercontent.com/theapache64/auto-motion/master/install.sh" -q --show-progress -O install.sh && sh install.sh && source ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

Usage πŸ–₯

usage: auto-motion -v input.mp4 [-H] -V <arg> [-BGM <arg>] [-ST <arg>]
       [-VL <arg>] [-MTL <arg>] [-TLS <arg>] [-ID <arg>] [-CR <arg>] [-WM
       <arg>] [-IT <arg>] [-CT <arg>] [-IST <arg>] [-CST <arg>] [-F <arg>]
       [-HL <arg>] [-WMC <arg>] [-WMS <arg>] [-WMBG <arg>] [-WMBGO <arg>]
       [-TFS <arg>] [-STFS <arg>] [-TC <arg>] [-STC <arg>] [-BG <arg>]
       [-RSRT <arg>] [-DSRT] [-RFMPG] [-sf] [-KS]
A tool to edit your lengthy screen records, automatically. Version
v1.0.0-alpha01
 -H,--help                              To print help text
 -V,--video <arg>                       Video inputs (required at least
                                        one)
 -BGM,--background-music <arg>          Background music for timelapse
                                        Default
                                        '/home/theapache64/Documents/proje
                                        cts/auto-motion/lab/lost_in_time.m
                                        p3'
 -ST,--sub-title <arg>                  Intro sub title
 -VL,--video-lang <arg>                 Video language. Default 'en'
 -MTL,--min-tl-src-len <arg>            Minimum timelapse source length
                                        (in seconds).
…

If you have some videos, download the code and run it on them to check out the output for fun. πŸ€ͺ

Thanks for reading!

I'm really happy I wrote this and I'm excited to share more with you all. If you liked the post, do share it with your friends. Feel free to post your suggestions for future posts! Thank you for reading this. Ciao!

man sending a flying kiss and saying "ciao"


P.S. Are you an Open-Source Enthusiast?

If you looking to build cool products in a collaborative environment and meet awesome people, I welcome you to join me in XenoX Multiverse πŸ”₯. Check out some of the stuff we made last year.

open arms join us gif

We are currently working on Caligator, one of the products we built last year which got great reception from you all and the good folks over at ProductHunt.

Caligator got a lot of traction and feature requests from people. Help us fire this up and take Caligator to the next level. Join chat on Gitter.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player