Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
352 views
in Technique[技术] by (71.8m points)

python - MoviePy write_videofile taking hours

I am trying to concatenate every clip in a directory as well as add an intro and outro. In the future I will also be adding editing functions such as zooms and rotations, which is why I am not directly calling ffmpeg, but instead using MoviePy.

Everything runs smoothly, until final_vid.write_videofile(). It first renders the audio at a fairly good speed.

chunk:  55%|█████▍    | 8721/15977 [00:14

When it then tries to render video, the speed slows down massively, to an expected rendering time of 72 hours. This is running on a ryzen 2600 with 16 gigs of ram, so I doubt the hardware is the bottleneck.

t:   0%|          | 5/43473 [00:28

I have tried this with different codecs, fps settings, logger off and multiple other settings. How would I go about speeding this up, since this cannot reasonably be the maximum speed of MoviePy?

Full code below:

def edit(game):
intro = VideoFileClip("intro.mp4")
final_vid = intro

game = game.replace(" ", "")
game_treated = game.replace(" ", "%20")

for clip_name in os.listdir("current_vids"):
    new_clip = VideoFileClip(os.path.join("current_vids", clip_name), target_resolution=(1920, 1080))

    final_vid = concatenate_videoclips(clips=[final_vid, new_clip], method="compose")

outro = VideoFileClip("outro.mp4")
final_vid = concatenate_videoclips(clips=(final_vid, outro), method="compose")

final_vid.write_videofile(game + datetime.today().strftime("%Y-%m-%d") + ".mp4")

for clip_name in os.listdir("current_vids"):
    os.remove(os.path.join("current_vids", clip_name))

return game_treated + datetime.today().strftime("%Y-%m-%d") + ".mp4"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...