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 Show MP4 Video Using Custom Width & Height in Command Line

Posted on February 12, 2023

Welcome folks today in this blog post we will be using the moviepy library to show mp4 video using custom width and height 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
# Import everything needed to edit video clips
from moviepy.editor import *
 
# loading video gfg
clip = VideoFileClip("geeks.mp4")
 
 
# showing 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 9 seconds of the input video using the subclip()method and then we are displaying the input video using the ipython_display() method. And also you can pass your custom width and height to this method as shown below

 

 

Showing Video Using Custom Width and Height

 

 

1
2
3
4
5
6
7
8
9
10
11
12
# Import everything needed to edit video clips
from moviepy.editor import *
 
# loading video dsa gfg intro video
clip = VideoFileClip("dsa_geek.webm")
 
# getting subclip as video is large
clip = clip.subclip(0, 10)
 
 
# showing clip
clip.ipython_display(width = 280, height = 320)

 

As you can see we are passing width and height as arguments to the ipython_display() method.

 

Recent Posts

  • Python 3 Openpyxl Script to Export Excel (.XLSX) File to PDF Document Using ReportLab Library
  • Node.js XPDF Tutorial to Export PDF File to Text and Save it as Audio File Using Say.js Module
  • Javascript Example to Validate Multi-Step HTML5 Form With Custom Error Messages in Browser
  • Javascript Wavesurfer.js Example to Generate Audio Waveform of Selected Audio File in Browser
  • Javascript Fabric.js Example to Export Drawing Canvas to Image & PDF Document in Browser
  • 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