Skip to content

WebNinjaDeveloper.com

Programming Tutorials




Menu
  • Home
  • Youtube Channel
  • Official Blog
  • Nearby Places Finder
  • Direction Route Finder
  • Distance & Time Calculator
Menu

Python 3 MoviePy Script to Change Opacity or Apply Color Filter in MP4 Video in Command Line

Posted on February 12, 2023

Welcome folks today in this blog post we will be using the moviepy library to change opacity or apply color filter inside mp4 videoin command line. All the full source code of the application is shown below.

 

 

Get Started

 

 

First of all we need to install the below moviepylibrary using the pip command as shown below

 

 

pip install moviepy

 

 

In order to get started you need to make an app.py file and copy paste the following code

 

 

app.py

 

 

Changing Opacity or Apply Color to Video

 

 

Now we will see how to change the opacity of existing video as shown below.

 

 

Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Import everything needed to edit video clips
from moviepy.editor import *
 
# loading video gfg
clip = VideoFileClip("video.mp4")
 
 
# getting subclip from it
clip = clip.subclip(0, 9)
 
 
# applying color effect
final = clip.fx( vfx.colorx, 0.3)
 
# showing final clip
final.ipython_display()

 

 

As you can see we are importing the moviepy library at the very top and then we are only taking the first 9 seconds of the input video using the subclip()method and then we are applying the color effect or changing the opacity of the video using the fx() method and inside it we are providing the numerical value if the value is larger then the opacity of the video will increase. And if the value is closer to 0 then the video will be more black in  color as shown below

 

 

 

Recent Posts

  • Android Java Project to Merge Multiple PDF Documents From Gallery Using iTextPDF Library
  • Android Java Project to Detect System Hardware & System CPU Info & Display inside TextView Widget
  • Android Java Project to Integrate Google OAuth2 Login & Logout System & Save User Info in SharedPreferences
  • Android Java Project to Export Raw Text to PDF Document Using iTextPDF Library
  • Android Java Project to Export Images From Gallery to PDF Document Using iTextPDF Library
  • Angular
  • Bunjs
  • C#
  • Deno
  • django
  • Electronjs
  • java
  • javascript
  • Koajs
  • kotlin
  • Laravel
  • meteorjs
  • Nestjs
  • Nextjs
  • Nodejs
  • PHP
  • Python
  • React
  • ReactNative
  • Svelte
  • Tutorials
  • Vuejs




©2023 WebNinjaDeveloper.com | Design: Newspaperly WordPress Theme