Ashish Jaiswar
Ashish Jaiswar

Ashish Jaiswar

Automate: Short quote videos using python

Ashish Jaiswar's photo
Ashish Jaiswar
·Aug 20, 2022·

3 min read

Automate: Short quote videos using python

Photo by Alexander Shatov on Unsplash

Table of contents

  • Introduction
  • Little background
  • Technologies I used
  • Requirements
  • Folder Structure
  • How to Install and Run
  • Credits

Introduction

Python is the most popular programming language out there. If you like automation like me then python is the best choice for you. It offers various automation tools and packages. In this blog, we will see how you can use python to edit your videos. we will use moviepy package to edit our videos. so without any further due let's get started.

This project creates and edits short videos using python. This application will create an awesome quote video of 15–20 sec. It will add music and quote to your video.

If you can automate things then why to do repetitive work

Little background

I was watching some short videos on Youtube and suddenly got the idea of creating short videos using python automation. Instantly I opened my laptop headed to the browser and started my research. It took me a week to complete this project from research to code to deployment.

Technologies I used

  • I used python as a programming language.
  • For editing videos, I used moviepy python package.
  • Used random quote generator API, check here.
  • Videos from pexels, other sources. Note: Resolution size must be 1080 * 1920.
  • Copyright Free audio.

Requirements

  • Python3. Download from here
  • moviepy package. Get it from here
  • ImageMagick application needs to be installed. Get it from here
  • video file with resolution 1080 x 1920. get it from here
  • music file

Folder Structure

automate_video_edit
    L audio
        L ColorFull Flowers.mp3
    L layer
        L black_layer.png
    L src
        L edit.py
        L quote.py
    app.py

How to Install and Run

Github project -> https://github.com/AshishJaiswar/automate_video_edit

Clone above github project

git clone https://github.com/AshishJaiswar/automate_video_edit

Move into the project

cd automate_video_edit

Create a virtual environment using cmd and switch to the created virtual environment. [Platform: Windows]

python -m venv venv
venv/Scripts/activate.bat

Install the packages using the below command

pip install -r requirement.txt

If you are using windows perform the below step. Mac users ignore this step. Go to path venv\Lib\site-packages\moviepy and edit the file config_defaults.py and update the IMAGEMAGICK_BINARY variable with the below path. for more details follow the doc.

IMAGEMAGICK_BINARY = fr"C:\Program Files\ImageMagick-7.1.0-Q16-HDRI\magick.exe"

Download the video from pexels.com and place it in the root folder.

Add a music file to the audio folder. It’s optional as I already added a music file for you.

Open the CMD/BASH on the root directory and run the below command

python app.py

After execution, a newly edited quote video file will be generated in your root directory.


Credits

  • Pexels: The best free stock photos, royalty-free images & videos shared by creators.
  • Youtubeaudio library: Copyright-free music.
  • quotable: Free public quotable API.

If you have any query/suggetions/feedback please connect with me on twitter

Meet you on the next blog. Enjoy Coding ❤

Did you find this article valuable?

Support Ashish Jaiswar by becoming a sponsor. Any amount is appreciated!

See recent sponsors Learn more about Hashnode Sponsors
 
Share this