简体   繁体   中英

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

I have several thousand short videos. They are all the same format (.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? 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.

Here's one approach on how to double a videos length with 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")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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