MoviePy - 使用 VideoFileClip 将剪辑附加到列表时出错
MoviePy - Error when appending Clips to List with VideoFileClip
我目前正在尝试创建一个脚本,将所有视频与文件夹中的特定结尾结合起来。
import os
from moviepy.editor import *
project_name = "manhattan4"
clips = []
for filename in os.listdir('renderings/'):
if filename.endswith(".mp4"):
clips.append(VideoFileClip(filename))
print(clips)
但是,我收到以下错误。
Traceback (most recent call last):
File "vid_merger.py", line 8, in <module>
clips.append(VideoFileClip(filename))
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/moviepy/video/io/VideoFileClip.py", line 88, in __init__
self.reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/moviepy/video/io/ffmpeg_reader.py", line 35, in __init__
infos = ffmpeg_parse_infos(filename, print_infos, check_duration,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/moviepy/video/io/ffmpeg_reader.py", line 270, in ffmpeg_parse_infos
raise IOError(("MoviePy error: the file %s could not be found!\n"
OSError: MoviePy error: the file render_7_manhattan4.mp4 could not be found!
Please check that you entered the correct path.
有趣的是,如果我不使用 VideoFileClip,即使使用 render_7_manhattan4.mp4,它也能正常工作。所以我对问题出在哪里一无所知。哪里有问题需要解决或如何解决?
因为您需要提供文件的完整路径。所以你可以这样做:
import os
from moviepy.editor import *
project_name = "manhattan4"
clips = []
for filename in os.listdir('renderings/'):
if filename.endswith(".mp4"):
clips.append(VideoFileClip('renderings/' + str(filename))) # Change here
print(clips)
我目前正在尝试创建一个脚本,将所有视频与文件夹中的特定结尾结合起来。
import os
from moviepy.editor import *
project_name = "manhattan4"
clips = []
for filename in os.listdir('renderings/'):
if filename.endswith(".mp4"):
clips.append(VideoFileClip(filename))
print(clips)
但是,我收到以下错误。
Traceback (most recent call last):
File "vid_merger.py", line 8, in <module>
clips.append(VideoFileClip(filename))
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/moviepy/video/io/VideoFileClip.py", line 88, in __init__
self.reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/moviepy/video/io/ffmpeg_reader.py", line 35, in __init__
infos = ffmpeg_parse_infos(filename, print_infos, check_duration,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/moviepy/video/io/ffmpeg_reader.py", line 270, in ffmpeg_parse_infos
raise IOError(("MoviePy error: the file %s could not be found!\n"
OSError: MoviePy error: the file render_7_manhattan4.mp4 could not be found!
Please check that you entered the correct path.
有趣的是,如果我不使用 VideoFileClip,即使使用 render_7_manhattan4.mp4,它也能正常工作。所以我对问题出在哪里一无所知。哪里有问题需要解决或如何解决?
因为您需要提供文件的完整路径。所以你可以这样做:
import os
from moviepy.editor import *
project_name = "manhattan4"
clips = []
for filename in os.listdir('renderings/'):
if filename.endswith(".mp4"):
clips.append(VideoFileClip('renderings/' + str(filename))) # Change here
print(clips)