Я пытаюсь добавить список видео вместе, чтобы сформировать uni c видео с Moviepy. У меня возникает эта ошибка при запуске моего кода:
chunk: 0%| | 0/11186 [00:00<?, ?it/s, now=None]
chunk: 0%| | 28/11186 [00:00<00:52, 212.69it/s, now=None]
chunk: 1%| | 76/11186 [00:00<00:43, 253.85it/s, now=None]Moviepy - Building video ../Media/Done/test.mp4.
MoviePy - Writing audio in testTEMP_MPY_wvf_snd.mp3
Traceback (most recent call last):
File "C:\Users\ricar\Documents\video_generator\Video_Creation\main.py", line 41, in <module>
main(sys.argv[1:])
File "C:\Users\ricar\Documents\video_generator\Video_Creation\main.py", line 31, in main
CreateFromVideos(VIDEOS_DIR)
File "C:\Users\ricar\Documents\video_generator\Video_Creation\CreateFromVideos.py", line 13, in __init__
self.createVideos()
File "C:\Users\ricar\Documents\video_generator\Video_Creation\CreateFromVideos.py", line 37, in createVideos
video.write_videofile('../Media/Done/test.mp4')
File "<decorator-gen-55>", line 2, in write_videofile
File "C:\Users\ricar\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\moviepy\decorators.py", line 54, in requires_duration
return f(clip, *a, **k)
File "<decorator-gen-54>", line 2, in write_videofile
File "C:\Users\ricar\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\moviepy\decorators.py", line 135, in use_clip_fps_by_default
return f(clip, *new_a, **new_kw)
File "<decorator-gen-53>", line 2, in write_videofile
File "C:\Users\ricar\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\moviepy\decorators.py", line 22, in convert_masks_to_RGB
return f(clip, *a, **k)
File "C:\Users\ricar\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\moviepy\video\VideoClip.py", line 293, in write_videofile
self.audio.write_audiofile(audiofile, audio_fps,
File "<decorator-gen-45>", line 2, in write_audiofile
File "C:\Users\ricar\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\moviepy\decorators.py", line 54, in requires_duration
return f(clip, *a, **k)
File "C:\Users\ricar\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\moviepy\audio\AudioClip.py", line 206, in write_audiofile
return ffmpeg_audiowrite(self, filename, fps, nbytes, buffersize,
File "<decorator-gen-9>", line 2, in ffmpeg_audiowrite
File "C:\Users\ricar\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\moviepy\decorators.py", line 54, in requires_duration
return f(clip, *a, **k)
File "C:\Users\ricar\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\moviepy\audio\io\ffmpeg_audiowriter.py", line 166, in ffmpeg_audiowrite
for chunk in clip.iter_chunks(chunksize=buffersize,
File "C:\Users\ricar\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\moviepy\audio\AudioClip.py", line 85, in iter_chunks
yield self.to_soundarray(tt, nbytes=nbytes, quantize=quantize,
File "<decorator-gen-44>", line 2, in to_soundarray
File "C:\Users\ricar\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\moviepy\decorators.py", line 54, in requires_duration
return f(clip, *a, **k)
File "C:\Users\ricar\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\moviepy\audio\AudioClip.py", line 127, in to_soundarray
snd_array = self.get_frame(tt)
File "<decorator-gen-11>", line 2, in get_frame
File "C:\Users\ricar\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\moviepy\decorators.py", line 89, in wrapper
return f(*new_a, **new_kw)
File "C:\Users\ricar\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\moviepy\Clip.py", line 93, in get_frame
return self.make_frame(t)
File "C:\Users\ricar\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\moviepy\audio\AudioClip.py", line 296, in make_frame
sounds = [c.get_frame(t - c.start)*np.array([part]).T
File "C:\Users\ricar\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\moviepy\audio\AudioClip.py", line 296, in <listcomp>
sounds = [c.get_frame(t - c.start)*np.array([part]).T
File "<decorator-gen-11>", line 2, in get_frame
File "C:\Users\ricar\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\moviepy\decorators.py", line 89, in wrapper
return f(*new_a, **new_kw)
File "C:\Users\ricar\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\moviepy\Clip.py", line 93, in get_frame
return self.make_frame(t)
File "C:\Users\ricar\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\moviepy\audio\io\AudioFileClip.py", line 77, in <lambda>
self.make_frame = lambda t: self.reader.get_frame(t)
File "C:\Users\ricar\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\moviepy\audio\io\readers.py", line 186, in get_frame
self.buffer_around(fr_max)
File "C:\Users\ricar\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\moviepy\audio\io\readers.py", line 240, in buffer_around
array = self.read_chunk(chunksize)
File "C:\Users\ricar\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\moviepy\audio\io\readers.py", line 113, in read_chunk
s = self.proc.stdout.read(L)
AttributeError: 'NoneType' object has no attribute 'stdout'
Я пробовал то, что здесь говорит, чтобы установить версию 1.0.0 Moviepy и запустить ее, но та же ошибка продолжает появляться. Я посмотрел на проблему Github , которая решает эту проблему, и в ней говорится, что она исправлена обновлением Moviepy, я пробовал это и тоже не работал. Вот мой код, может ли кто-нибудь помочь?
import os, os.path
import random
from moviepy.editor import *
class CreateFromVideos:
def __init__(self,videosDir):
self.videosDir = videosDir
self.list_of_videos = [name for name in os.listdir(self.videosDir) if os.path.isfile(os.path.join(self.videosDir, name))]
self.num_of_videos = len(self.list_of_videos)
self.list_of_rand_nums = []
self.list_of_videos = []
self.video_duration = 0
self.createVideos()
def createVideos(self):
while(self.video_duration < 420):
rand_num = random.randint(1,self.num_of_videos)
#Create a list with all the videos that will be used
if rand_num not in self.list_of_rand_nums:
#Add the random number to the list of rand nums
self.list_of_rand_nums.append(rand_num)
#load the video
idividual_clip = VideoFileClip("../Media/Videos/" + str(rand_num) + ".mp4")
#add the video with the rest of videos
self.list_of_videos.append(idividual_clip)
self.video_duration += idividual_clip.duration
idividual_clip.reader.close()
idividual_clip.audio.reader.close_proc()
#Generate the video
video = concatenate_videoclips(self.list_of_videos,method="compose")
video.write_videofile('../Media/Done/test.mp4')