简体   繁体   中英

MoviePy Output Video crazy distortion

Heyy guys, I just used MoviePy for the first time and at the beginning it worked totally fine. But then after the third clip (sec 34) I observed a weird disruption. I have no words for it but please take a look at it and the code below. Each of the clips is flawless as itself. What could be the reason for it? Thanks in advance! https://www.dropbox.com/s/v7aur2h6nej751p/my_tiktok_compilation.mp4?dl=0

from moviepy.editor import VideoFileClip, concatenate_videoclips
import os, os.path


## Cutting the Clips ##
all_clips = []

# folder path
dir_path = r'./clips'
count = 0
# Iterate directory
for path in os.listdir(dir_path):
    # check if current path is a file
    if os.path.isfile(os.path.join(dir_path, path)):
        count += 1
        clip = VideoFileClip(f"./clips/{path}")
        #clip.set_position("center") # automatically centered
        all_clips.append(clip)

print('File count:', count)

final_clip = concatenate_videoclips(all_clips)
final_clip.write_videofile("my_tiktok_compilation.mp4")

Try to concatenate with method argument set to compose :

final_clip = concatenate_videoclips(all_clips, method="compose")

From the docstring:

method="compose", if the clips do not have the same resolution, the final resolution will be such that no clip has to be resized. As a consequence the final clip has the height of the highest clip and the width of the widest clip of the list. All the clips with smaller dimensions will appear centered. The border will be transparent if mask=True, else it will be of the color specified by bg_color .

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