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 Get & Set FPS Value of Input Video File in Command Line

Posted on February 12, 2023

Welcome folks today in this blog post we will be using the moviepy library to get the FPS value of the input video file in 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

 

 

Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Import everything needed to edit video clips
from moviepy.editor import *
 
# loading video dsa gfg intro video
clip = VideoFileClip("video.mp4").subclip(0, 10)
 
 
# getting frame rate of the clip
rate = clip.fps
 
# printing the fps
print("FPS : " + str(rate))
 
 
print("---------------------------------------")
 
 
# showing final clip
clip.ipython_display()

 

 

As you can see we are importing the moviepy library at the very top and then we are only taking the first 5 seconds of the input video using the subclip()method and then we are getting the frames per second of the video using the .fps property and now if you execute it you will see the below result of fps

 

 

 

 

Setting the FPS Value of Video

 

 

Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Import everything needed to edit video clips
from moviepy.editor import *
# loading video dsa gfg intro video
clip = VideoFileClip("dsa_geek.mp4")
# getting only first 5 seconds
clip = clip.subclip(0, 5)
 
# new clip with new fps
new_clip = clip.set_fps(5)
 
# displaying new clip
new_clip.ipython_display(width = 360)

 

 

As you can see we are repeating the same steps but here we are using the set_fps() method to set the fps for the video file and in the argument we are passing the fps value in numbers.

 

Recent Posts

  • How to Add Let’s Encrypt SSL Certificate to Domain Using Certbot in Nginx
  • Node.js Fluent-FFMPEG Audio Pitch & Speed Changer With Live Preview in Browser Using Express
  • React.js react-awesome-modal Example to Show Popup Modal With Animation in Browser Using Javascript
  • Node.js Express Server Side Form Validation With Custom Error Messages Using express-validator Library in Javascript
  • Node.js Express Project to Validate User Form Data Using joi Schema Validation Library Full Example
  • 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