0

when i tried to run this code, i got the "AttributeError" but idk why? please help me.

import os
import random
from moviepy.editor import *

List_image = os.listdir("müzik\kapaklar")
kapak_num = random.sample(range(1,len(List_image)+1),len(List_image))

List_songs = os.listdir("müzik\hazırlanacaklar")

for x in range(len(List_songs)):
   songs = List_songs[x+1]
   kapak = List_image[kapak_num[x+1]]

   audio = AudioFileClip(songs) ### problem is here ###

   image = ImageClip(kapak).set_duration(audio.duration)
   video = image.set_audio(audio)
   outfile = f"müzik\yapılanlar\%n_with_image.mp4",songs 

   video.write_videofile(outfile, fps=1)

error message:

C:\Users\erkan\Desktop\ChatCop\venv\Scripts\python.exe "C:/Users/erkan/Desktop/ChatCop/deus ex machina.py"
Traceback (most recent call last):
  File "C:/Users/erkan/Desktop/ChatCop/deus ex machina.py", line 15, in <module>
    audio = AudioFileClip(songs) # sıkıntı burada
  File "C:\Users\erkan\Desktop\ChatCop\venv\lib\site-packages\moviepy\audio\io\AudioFileClip.py", line 72, in __init__
    buffersize=buffersize)
  File "C:\Users\erkan\Desktop\ChatCop\venv\lib\site-packages\moviepy\audio\io\readers.py", line 50, in __init__
    infos = ffmpeg_parse_infos(filename)
  File "C:\Users\erkan\Desktop\ChatCop\venv\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 276, in ffmpeg_parse_infos
    "path.")%filename)
OSError: MoviePy error: the file 70s Japanese Jazz Mix (Rare Groove, Jazz-Funk, Hard Bop, Modal, Fusion, Breaks).mp3 could not be found!
Please check that you entered the correct path.
Exception ignored in: <bound method AudioFileClip.__del__ of <moviepy.audio.io.AudioFileClip.AudioFileClip object at 0x0000026210D45710>>
Traceback (most recent call last):
  File "C:\Users\erkan\Desktop\ChatCop\venv\lib\site-packages\moviepy\audio\io\AudioFileClip.py", line 94, in __del__
    self.close()
  File "C:\Users\erkan\Desktop\ChatCop\venv\lib\site-packages\moviepy\audio\io\AudioFileClip.py", line 89, in close
    if self.reader:
AttributeError: 'AudioFileClip' object has no attribute 'reader'

Process finished with exit code 1
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
rknksy
  • 21
  • 5
  • 1
    show the complete error message – eyllanesc Jan 04 '20 at 20:34
  • It appears that it can't find an audio file you're trying to use. The AttributeError looks like a result of the error being ignored after the AudioFileClip's creation. – TechPerson Jan 04 '20 at 20:59
  • from the error message: *...OSError: MoviePy error: the file 70s Japanese Jazz Mix (Rare Groove, Jazz-Funk, Hard Bop, Modal, Fusion, Breaks).mp3 could not be found! Please check that you entered the correct path....* – eyllanesc Jan 04 '20 at 21:00

0 Answers0