Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Resize a Video Clip in Python

I want to resize a video clip in python 2.7.

For example we give "movie.mp4" with 1080p quality The result should be "movie.mp4" with 360p quality

I Think that there should be solutions with Moviepy. If you know a solution with it.

I would be grateful if you answer me.

like image 774
Seyed Ali Akhavani Avatar asked Feb 06 '15 07:02

Seyed Ali Akhavani


People also ask

How do you resize a frame in Python?

Build A Paint Program With TKinter and Python Considering the case, if you want to configure the size of the frame explicitly, you can use the pack() geometry manager by specifying the side and padding property. The pack() geometry manager gives proper accessibility to the widget for resizing.

What is VideoFileClip?

A video clip originating from a movie file. For instance: >>> clip = VideoFileClip("myHolidays.

How do you fast forward a video in Python?

MoviePy is a Python module for video editing, which can be used for basic operations on videos and GIF's. Speed up video or slow down also known as fast motion/slow-motion effects in video production, which makes the video clips play faster or slower than original speed.


1 Answers

Here is how you resize a movie with moviepy: see the mpviepy doc here

import moviepy.editor as mp
clip = mp.VideoFileClip("movie.mp4")
clip_resized = clip.resize(height=360) # make the height 360px ( According to moviePy documenation The width is then computed so that the width/height ratio is conserved.)
clip_resized.write_videofile("movie_resized.mp4")

You can also tune the quality by adding the parameter bitrate="500k" or bitrate="5000k" in the last line.

As said above, you could also use ffmpeg directly, it will be simpler if you just need a quick script.

like image 156
Zulko Avatar answered Sep 18 '22 05:09

Zulko