剪下一部分视频——python [英] Cutting out a portion of video - python

查看:34
本文介绍了剪下一部分视频——python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有每个大约 25 分钟的视频,我希望从一开始就使用 python 缩短几秒钟.

I have videos of length approximately 25 min each and I wish to cut a few seconds from the start using python.

搜索它,我偶然发现了 python 的 moviepy 包.问题是,即使是单个视频也需要花费大量时间.以下是我用来从单个视频的开头剪切 7 秒的代码片段.写入过程消耗大量时间.有没有更好的方法来使用 python 剪切视频?

Searching about it, I stumbled upon the moviepy package for python. The problem is, it takes up a lot of time even for a single video. Following is the code snippet I use to cut 7 seconds from the start of a single video. The write process consumes a lot of time. Is there a better way to cut the videos using python?

from moviepy.editor import *
clip = VideoFileClip("video1.mp4").cutout(0, 7)
clip.write_videofile("test.mp4")

如果我遗漏了任何细节,请告诉我.

Please let me know if I have missed out any details.

感谢任何帮助.谢谢!

推荐答案

试试这个,告诉我们是否更快(如果可以,它会直接使用ffmpeg提取视频,无需解码和重新编码):

Try this and tell us if it is faster (if it can, it will extract the video directly using ffmpeg, without decoding and reencoding):

from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
ffmpeg_extract_subclip("video1.mp4", start_time, end_time, targetname="test.mp4")

如果这没有帮助,请查看 代码

If that doesn't help, have a look at the code

这篇关于剪下一部分视频——python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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