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?
"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,
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.
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. π€
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!
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.
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.
Article No Longer Available
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.