DEV Community

Cover image for AutoMotion: How I Automated My Video Editing Process
theapache64 for XenoX

Posted on

AutoMotion: How I Automated My Video Editing Process

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.

Top comments (18)

Collapse
 
hinasoftwareengineer profile image
Hina-softwareEngineer

Amazing project and article!!!! Which skills are needed to join Xenox.

Collapse
 
utkarsh profile image
Utkarsh Talwar

Hi Hina. If you know basic HTML/CSS and javascript, you're good to go! You can browse our projects to see which one you'd like to contribute to. I see on your profile that you're a student currently trying to find a solid direction for yourself. That's great, we have many students among us, and our senior members love mentoring youngsters. If you'd like, I can connect you to one of them. Cheers! πŸ˜„

Collapse
 
hinasoftwareengineer profile image
Hina-softwareEngineer

Yes, i want to join. I know html5, css, JavaScript, nodejs very well. Also know python. Now, i am learning react. i am browsing Projects and will tell you on which i contribute.

Thread Thread
 
utkarsh profile image
Utkarsh Talwar

That's awesome. We have an active Telegram group for Xenox Multiverse where all the action takes place. Let me know your Telegram handle if you'd like me to add you there. You can also start by adding your name here.

Thread Thread
 
hinasoftwareengineer profile image
Hina-softwareEngineer • Edited

My telegram account name is HINA KHADIM. Ok i will add my name on github.πŸ˜ƒπŸ˜ƒ

Thread Thread
 
utkarsh profile image
Utkarsh Talwar

Couldn't find you on Telegram. Drop me a text on @YouuTeee 😊

Collapse
 
bassemibrahim profile image
Bassem

Awesome project, great article πŸ”₯πŸ”₯

Collapse
 
theapache64 profile image
theapache64 • Edited

Thank you so much Basseem. πŸ˜€

Collapse
 
djamsons profile image
dajames

I really like this project, already done some test but i hate using automated video because i don't want face new issue. Any way i enjoyed so much here and i prefer using web to use this whole process by using new working kahoot hacks auto answer to finish every step in easy way.

Collapse
 
gogojina profile image
gogojina

I was streaming youtube videos but no luck, my dream is to become amazing youtuber, I feel need more tests to see what really work fine.
learn.acloud.guru/profile/quick-hi...

Collapse
 
anissa profile image
mirkana

I decided to do the same, i will never give up and i will try the process until i found a solution.

my link: myget.org/feed/edgenuity-cheat/pac...

Collapse
 
adgower profile image
Alex Gower

Cool project thanks for sharing

Collapse
 
theapache64 profile image
theapache64

You're welcome :)

Collapse
 
andrioid profile image
Andri

A really cool idea, and addresses what has been keeping me from doing videos.

Doing stuff like this programtically really speaks to me. Nice work!

Collapse
 
theapache64 profile image
theapache64

First of all, sorry for the late reply. I really appreciate the time you took to read the blog. Thank you :)

Collapse
 
johnniebennett profile image
JohnnieBennett • Edited

You can install similar app to edit video with beautiful effects and quality on powerdirector mod apk app at techbigs.com/powerdirector.html

Collapse
 
socialevil profile image
Jon Mahat

You can install similar app to edit video with beautiful effects and quality from apkworlds.com/

Collapse
 
derboura profile image
derboura mikes

automotion is active action where all the editing process take more time, i wanna tryi soon as i can.

My links : foundation.app/@freeluckycrush