如何在Python中调整视频剪辑的大小 [英] How To Resize a Video Clip in Python

查看:1749
本文介绍了如何在Python中调整视频剪辑的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在python 2.7中调整视频剪辑的大小.

I want to resize a video clip in python 2.7.

例如,我们给"movie.mp4"提供1080p的质量 结果应为360p质量的"movie.mp4"

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

我认为Moviepy应该有解决方案.如果您知道解决方案.

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

如果您回答我,我将不胜感激.

I would be grateful if you answer me.

推荐答案

以下是通过moviepy调整电影大小的方法:

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")

您还可以通过在最后一行中添加参数bitrate="500k"bitrate="5000k"来调整质量.

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

如上所述,您也可以直接使用ffmpeg,如果只需要快速脚本,它将更加简单.

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

这篇关于如何在Python中调整视频剪辑的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆