簡體   English   中英

類型錯誤:“功能”object 不可下標 python。 我試圖將每個.mp4 文件合並到一個視頻中

[英]TypeError: 'function' object is not subscriptable python. Im trying to combine every .mp4 file into one video

我正在嘗試將 certin 文件夾中的每個 .mp4 文件合並為一個單個 .mp4 文件

video_files = glob.glob("*.mp4")
print(video_files)


final = concatenate_videoclips[video_files]
final.write_videofile("new.mp4", codec="libx264") 

我得到的錯誤是

final = concatenate_videoclips[video_files];
TypeError: 'function' object is not subscriptable

如果有人能解釋我做錯了什么,我將不勝感激。

首先,可下標部分意味着您應該使用( and )而不是[ and ] 其次,不能簡單地將文件名放入 function 中,需要先將它們轉換為VideoFileClip

# from moviepy.editor import VideoFileClip,concatenate_videoclips
# import glob

video_files = glob.glob("*.mp4")

clips = []

for clip in video_files: # For each mp4 file name
    clips.append(VideoFileClip(clip)) # Store them as a VideoFileClip and add to the clips list


final = concatenate_videoclips(clips) # Concatenate the VideoFileClips
final.write_videofile("new.mp4", codec="libx264") 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM