How To Resize a Video Clip in Python

后端 未结 2 1670
日久生厌
日久生厌 2021-02-05 17:00

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 th

相关标签:
2条回答
  • 2021-02-05 17:30

    Why not ffmpeg?

    ffmpeg -i movie.mp4 -vf scale=640:360 movie_360p.mp4
    

    If you use 640:-2 then, in this example, the scale filter will preserve the aspect ratio and automatically calculate the correct height.

    Look at the H.264 encoding guide for additional options.

    0 讨论(0)
  • 2021-02-05 17:31

    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.

    0 讨论(0)
提交回复
热议问题