0

code:

from moviepy.editor import *
import os

Pictures = []

Path = 'Pictures_To_Use'

#Adding Pics to the Pictures arrray
for pics in os.listdir(Path):
    clips = ImageClip(pics).set_duration(5)
    Pictures.append(Path + "/" + pics)
    
#UI
Title = input("Please input a title:")
print("-" * 36)
print("Title:" + Title)
print("-" * 36)
print("The Following Pictures will be Used:")
print(Pictures)
print("-" * 36)

#Export video
video = concatenate_videoclips(clips, method="compose")
video.write_videofile(Title, fps=30)

error:

PS C:\Users\GeekZoid\Desktop\YTVideo Maker> python -u "c:\Users\GeekZoid\Desktop\YTVideo Maker\Main.py"
Traceback (most recent call last):
  File "c:\Users\GeekZoid\Desktop\YTVideo Maker\Main.py", line 10, in <module>
    clips = ImageClip(pics).set_duration(5)
            ^^^^^^^^^^^^^^^
  File "C:\Users\GeekZoid\AppData\Local\Programs\Python\Python311\Lib\site-packages\moviepy\video\VideoClip.py", line 889, in __init__
    img = imread(img)
          ^^^^^^^^^^^
  File "C:\Users\GeekZoid\AppData\Local\Programs\Python\Python311\Lib\site-packages\imageio\__init__.py", line 97, in imread
    return imread_v2(uri, format=format, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\GeekZoid\AppData\Local\Programs\Python\Python311\Lib\site-packages\imageio\v2.py", line 226, in imread
    with imopen(uri, "ri", **imopen_args) as file:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\GeekZoid\AppData\Local\Programs\Python\Python311\Lib\site-packages\imageio\core\imopen.py", line 113, in imopen      
    request = Request(uri, io_mode, format_hint=format_hint, extension=extension)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\GeekZoid\AppData\Local\Programs\Python\Python311\Lib\site-packages\imageio\core\request.py", line 248, in __init__
    self._parse_uri(uri)
  File "C:\Users\GeekZoid\AppData\Local\Programs\Python\Python311\Lib\site-packages\imageio\core\request.py", line 408, in _parse_uri
    raise FileNotFoundError("No such file: '%s'" % fn)
FileNotFoundError: No such file: 'C:\Users\GeekZoid\Desktop\YTVideo Maker\Meme1.jpg

I have tried appending the File to an array as a path. I also tried using a for loop to run through the pictures array to set the duration of the pictures, But none of those solutions worked

Xiddoc
  • 3,369
  • 3
  • 11
  • 37
  • I'm pretty sure that "C:\Users\GeekZoid\Desktop\YTVideo Maker\Meme1.jpg" does not exist on your drive, you should check that first. The error message doesn't show the last "'", if there wasn't one, you have extra spaces in your file name with could cause the error, too. – 576i Dec 20 '22 at 11:20
  • It does thats the path to the Photos – pugnacious unrest Dec 20 '22 at 11:22
  • Does this answer your question? [How to avoid a FileNotFoundError with os.listdir (duplicate)](https://stackoverflow.com/q/57761583/6045800) – Tomerikoo Dec 20 '22 at 11:49
  • I modified the for loop but it still doesnt work – pugnacious unrest Dec 20 '22 at 12:20
  • If i remove clips = ImageClip(pics).set_duration(5) then i get this error: video = concatenate_videoclips(clips, method="compose") ^^^^^ NameError: name 'clips' is not defined – pugnacious unrest Dec 20 '22 at 12:21

0 Answers0