简体   繁体   English

使用Python / OpenCV将mp4视频的长度加倍?

[英]Use Python/ OpenCV to double the length of an mp4 video?

I have several thousand short videos. 我有几千个短片。 They are all the same format (.mp4). 它们都是相同的格式(.mp4)。 Is it possible to use python and or http://docs.opencv.org/3.0-beta/modules/videoio/doc/reading_and_writing_video.html to double the video length, by looping through all frames and copying them, then appending them to the same file? 是否可以使用python和或http://docs.opencv.org/3.0-beta/modules/videoio/doc/reading_and_writing_video.html将视频长度加倍,方法是循环遍历所有帧并将其复制,然后将其附加到相同的文件? Or am I barking up the entirely wrong tree given the available tools? 还是我在使用可用工具的情况下就完全错了?

Thanks 谢谢

Not sure about opencv, but moviepy should do exactly what you want. 不确定opencv,但moviepy应该可以完全满足您的要求。

Here's one approach on how to double a videos length with moviepy: 这是一种关于如何用moviepy将视频长度加倍的方法:

from moviepy.editor import VideoFileClip, concatenate_videoclips

#load video file
clip = VideoFileClip("video.mp4")

#concatenate same video file two times
final_clip = concatenate_videoclips([clip, clip])

#write new video file (2 times the length of the original)
final_clip.write_videofile("new_video.mp4")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM