Zulko / moviepy

Video editing with Python
https://zulko.github.io/moviepy/
MIT License
12.34k stars 1.55k forks source link

Glitchy result when concatenating videoclips #1697

Open NadiaP7406 opened 2 years ago

NadiaP7406 commented 2 years ago

Hi all,

I'm having a problem with concatenate videoclips. I've tried first seperating subclips and this works fine, then I tried concatenating them all into one video. I do not get any sort of error but when I open the video, the results after 10 seconds (so from the 3rd small clip) are extremely glitchy.

I've uploaded the result on Youtube so you can see what I mean:

<iframe width="560" height="315" src="https://www.youtube.com/embed/mElU9H8BTJ8" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

I've tried with different files, lengths etc. but it always does it starting from the 3rd video.

Here is my code:

from moviepy import *
from moviepy.editor import *
from moviepy.editor import concatenate_videoclips

clip3 = VideoFileClip("1958_InformationMachine_512kb.mp4").subclip(60,65)
clip4 = VideoFileClip("1959_AllAboutPolymorphics_512kb.mp4").subclip(60,65)
clip5 = VideoFileClip("1968_0767_Incredible_Machine_The_20_26_47_00_3mb.mp4").subclip(60,65)
clip6 = VideoFileClip("1970_0559_Threads_of_Technology_09_12_29_01_3mb.mp4").subclip(60,65)
clip7 = VideoFileClip("1996_Noorderlicht - Creative Computers.mp4").subclip(60,65)
clip8 = VideoFileClip("2003_logic_by_machine_1_512kb.mp4").subclip(60,65)
clip9 = VideoFileClip("2016_AI_s_Game_Playing_Challenge_-_Computerphile-5oXyibEgJr0.mp4").subclip(60,65)
final_clip = concatenate_videoclips([clip5,clip6,clip7]) #clip6,clip7,clip8,clip9
final_clip.write_videofile("my_concatenation_smaller.mp4")

Does anybody have an idea what's up? Any pointers would be super helpful! Thank you :)

tylerweston commented 2 years ago

Two problems I found that gave me glitchy results where the videos not being the same FPS and the concatenation mode for when I concatenated clips. To solve the first problem, on each clip, I called .set_fps(fps) and then when concatenating clips, I used the method="compose" option. I'm not sure entirely which step solved my problem but after I did those two things, my videos stopped being glitchy.