aahashemi / YouTubeAutomation-Reddit

GNU General Public License v3.0
216 stars 57 forks source link

Cannot work out where the problem is coming from? #4

Closed dazeb closed 4 months ago

dazeb commented 1 year ago

Hi, thanks for the work its a great script but unfortunately i get an error right at the end.

Starting ..........

Logged in to Reddit successfully!
Chosen thread: What is the all time greatest driving song? -- Score: 25062
10 comments are chosen
Launching Headless Browser...
Screenshots downloaded Successfully.
Getting mp3 files..
Creating the final video πŸŽ₯
Proc not detected
Video Will Be: 30 Seconds Long
Moviepy - Building video ./Results/10fpkg3.mp4.
MoviePy - Writing audio in 10fpkg3TEMP_MPY_wvf_snd.mp4
MoviePy - Done.                                                                      
Moviepy - Writing video ./Results/10fpkg3.mp4

t:   0%|                                   | 2/720 [00:00<01:03, 11.30it/s, now=None]Traceback (most recent call last):
  File "/home/dazeb/Documents/code/github/YouTubeAutomation-Reddit/.venv/lib/python3.10/site-packages/moviepy/video/io/ffmpeg_writer.py", line 143, in write_frame
    self.proc.stdin.write(img_array.tobytes())
BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/dazeb/Documents/code/github/YouTubeAutomation-Reddit/main.py", line 110, in <module>
    main()
  File "/home/dazeb/Documents/code/github/YouTubeAutomation-Reddit/main.py", line 90, in main
    make_final_video(title_audio_path=title_audio_clean_path,
  File "/home/dazeb/Documents/code/github/YouTubeAutomation-Reddit/VideoEditor/videomaker.py", line 110, in make_final_video
    final.write_videofile(
  File "<decorator-gen-60>", line 2, in write_videofile
  File "/home/dazeb/Documents/code/github/YouTubeAutomation-Reddit/.venv/lib/python3.10/site-packages/moviepy/decorators.py", line 56, in requires_duration
    return f(clip, *a, **k)
  File "<decorator-gen-59>", line 2, in write_videofile
  File "/home/dazeb/Documents/code/github/YouTubeAutomation-Reddit/.venv/lib/python3.10/site-packages/moviepy/decorators.py", line 135, in use_clip_fps_by_default
    return f(clip, *new_a, **new_kw)
  File "<decorator-gen-58>", line 2, in write_videofile
  File "/home/dazeb/Documents/code/github/YouTubeAutomation-Reddit/.venv/lib/python3.10/site-packages/moviepy/decorators.py", line 24, in convert_masks_to_RGB
    return f(clip, *a, **k)
  File "<decorator-gen-57>", line 2, in write_videofile
  File "/home/dazeb/Documents/code/github/YouTubeAutomation-Reddit/.venv/lib/python3.10/site-packages/moviepy/decorators.py", line 89, in wrapper
    return f(*new_a, **new_kw)
  File "/home/dazeb/Documents/code/github/YouTubeAutomation-Reddit/.venv/lib/python3.10/site-packages/moviepy/video/VideoClip.py", line 343, in write_videofile
    ffmpeg_write_video(
  File "/home/dazeb/Documents/code/github/YouTubeAutomation-Reddit/.venv/lib/python3.10/site-packages/moviepy/video/io/ffmpeg_writer.py", line 265, in ffmpeg_write_video
    writer.write_frame(frame)
  File "/home/dazeb/Documents/code/github/YouTubeAutomation-Reddit/.venv/lib/python3.10/site-packages/moviepy/video/io/ffmpeg_writer.py", line 196, in write_frame
    raise IOError(error)
OSError: [Errno 32] Broken pipe

MoviePy error: FFMPEG encountered the following error while writing file ./Results/10fpkg3.mp4:

 ./Results/10fpkg3.mp4: No such file or directory

Do you have any idea what may fix this?

Thank you

akashanuj commented 1 year ago

looks to me like it cannot write to the directory "./Results/"

Just run: sudo mkdir ./Results

then rerun the script

streled commented 1 year ago

Hi, I had the exact same error, and after running sudo mkdir ./Results, like @akashanuj said, I got a different error:

pi@raspberrypi:~/Documents/YouTubeAutomation-Reddit $ python main.py
Starting ..........

Logged in to Reddit successfully!
Chosen thread: What hobby is an immediate red flag? -- Score: 32465
10 comments are chosen
Launching Headless Browser...
Screenshots downloaded Successfully.
Getting mp3 files..
Creating the final video πŸŽ₯
Proc not detected
Video Will Be: 60 Seconds Long
Moviepy - Building video ./Results/10kv4yc.mp4.
MoviePy - Writing audio in 10kv4ycTEMP_MPY_wvf_snd.mp4
MoviePy - Done.                                                                                                                                                                                       
Moviepy - Writing video ./Results/10kv4yc.mp4

t:   0%|▏                                                                                                                                                  | 2/1440 [00:00<06:48,  3.52it/s, now=None]Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.9/site-packages/moviepy/video/io/ffmpeg_writer.py", line 143, in write_frame
    self.proc.stdin.write(img_array.tobytes())
BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/Documents/YouTubeAutomation-Reddit/main.py", line 110, in <module>
    main()
  File "/home/pi/Documents/YouTubeAutomation-Reddit/main.py", line 90, in main
    make_final_video(title_audio_path=title_audio_clean_path,
  File "/home/pi/Documents/YouTubeAutomation-Reddit/VideoEditor/videomaker.py", line 110, in make_final_video
    final.write_videofile(
  File "<decorator-gen-60>", line 2, in write_videofile
  File "/home/pi/.local/lib/python3.9/site-packages/moviepy/decorators.py", line 56, in requires_duration
    return f(clip, *a, **k)
  File "<decorator-gen-59>", line 2, in write_videofile
  File "/home/pi/.local/lib/python3.9/site-packages/moviepy/decorators.py", line 135, in use_clip_fps_by_default
    return f(clip, *new_a, **new_kw)
  File "<decorator-gen-58>", line 2, in write_videofile
  File "/home/pi/.local/lib/python3.9/site-packages/moviepy/decorators.py", line 24, in convert_masks_to_RGB
    return f(clip, *a, **k)
  File "<decorator-gen-57>", line 2, in write_videofile
  File "/home/pi/.local/lib/python3.9/site-packages/moviepy/decorators.py", line 89, in wrapper
    return f(*new_a, **new_kw)
  File "/home/pi/.local/lib/python3.9/site-packages/moviepy/video/VideoClip.py", line 343, in write_videofile
    ffmpeg_write_video(
  File "/home/pi/.local/lib/python3.9/site-packages/moviepy/video/io/ffmpeg_writer.py", line 265, in ffmpeg_write_video
    writer.write_frame(frame)
  File "/home/pi/.local/lib/python3.9/site-packages/moviepy/video/io/ffmpeg_writer.py", line 196, in write_frame
    raise IOError(error)
OSError: [Errno 32] Broken pipe

MoviePy error: FFMPEG encountered the following error while writing file ./Results/10kv4yc.mp4:

 ./Results/10kv4yc.mp4: Permission denied

Since it says "Permission denied", I tried running the script with sudo, but this gives me this error:

pi@raspberrypi:~/Documents/YouTubeAutomation-Reddit $ sudo python main.py
Traceback (most recent call last):
  File "/home/pi/Documents/YouTubeAutomation-Reddit/main.py", line 2, in <module>
    from Reddit import reddit
  File "/home/pi/Documents/YouTubeAutomation-Reddit/Reddit/reddit.py", line 2, in <module>
    import praw
ModuleNotFoundError: No module named 'praw'

I then tried reinstalling praw, but this just gave me a bunch of Requirement already statisfied: ... .

Do you have any idea what could cause this?

Thanks!

mattexpa commented 1 year ago

This is likely due to filesystems behaving differently under certain OS'es (i guess you're using OSX?). A functional workaround to this problem would be to edit videomaker.py located in the VideoEditor folder of this project.

Search for final.write_videofile and in the line below edit f"./Results/{subreddit}.mp4", to the actual path your project is located in. For example USING MAC OS it could be something like f"/Users/insertusernamehere/Desktop/RedditAutomationYoutube/Results/{subreddit}.mp4",

After that you have to create the folder Results in the main project folder - execute, done!