elebumm / RedditVideoMakerBot

Create Reddit Videos with just✨ one command ✨
GNU General Public License v3.0
6.63k stars 1.85k forks source link

Moviepy throwing an Error #348

Closed TrueWLAN closed 2 years ago

TrueWLAN commented 2 years ago

Description of the Bug: After Running the Script, it works till the Finding a spot in the background video to chop Function, this Function throws an Error.

To Reproduce Follow this Tutorial for Installation. https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax run python3 main.py

Expected behavior Finding a Spot in the Video and continuing with the Script.

What is Happening Throwing an Error on Finding a spot in the background video to chop process.

Code

C:\Users\Max\Documents\tiktok bot>python3 main.py

                                Thanks for using this tool! Feel free to contribute to this project on GitHub! If you have any questions, feel free to reach out to me on Twitter or submit a GitHub issue.

[21:21:45] Checking environment variables...                                                                                                                                                                                      main.py:48
[21:21:46] Enviroment Variables are set! Continuing...                                                                                                                                                                            main.py:90
Insert the full thread link:
https://www.reddit.com/r/AskReddit/comments/v5jtw5/women_of_reddit_what_things_do_men_do_that/
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Getting the inserted thread...                                                                                                                                                                                                           │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Video will be: Women of Reddit, what things do men do that frighten you without them even realizing it? 👍
[21:22:27] Getting video comments...                                                                                                                                                                                         subreddit.py:61
Received AskReddit threads successfully.
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Saving Text to MP3 files...                                                                                                                                                                                                              │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Saving... ---------------------------------------- 0.4 it/s
Saved Text to MP3 files successfully.
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Downloading Screenshots of Reddit Posts 📷                                                                                                                                                                                               │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Launching Headless Browser...
Downloading screenshots... ---------------------------------------- 0.3 it/s
Screenshots downloaded Successfully.
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Finding a spot in the background video to chop...                                                                                                                                                                                        │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Moviepy - Running:
>>> "+ " ".join(cmd)
Moviepy - Command returned an error
Traceback (most recent call last):
  File "C:\Users\Max\Documents\tiktok bot\main.py", line 99, in <module>
    chop_background_video(length)
  File "C:\Users\Max\Documents\tiktok bot\video_creation\background.py", line 45, in chop_background_video
    ffmpeg_extract_subclip(
  File "C:\Users\Max\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\moviepy\video\io\ffmpeg_tools.py", line 41, in ffmpeg_extract_subclip
    subprocess_call(cmd)
  File "C:\Users\Max\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\moviepy\tools.py", line 54, in subprocess_call
    raise IOError(err.decode('utf8'))
OSError: ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.2.1 (GCC) 20200122
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'assets/mp4/background.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf58.76.100
  Duration: 01:20:13.08, start: 0.000000, bitrate: 10571 kb/s
    Stream #0:0(eng): Video: vp9 (Profile 0) (vp09 / 0x39307076), yuv420p(tv, bt709), 2560x1440, 10419 kb/s, SAR 1:1 DAR 16:9, 59.90 fps, 59.94 tbr, 16k tbn, 16k tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: opus (Opus / 0x7375704F), 48000 Hz, stereo, fltp, 137 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
[mp4 @ 0000017b971dfec0] track 1: codec frame size is not set
[mp4 @ 0000017b971dfec0] opus in MP4 support is experimental, add '-strict -2' if you want to use it.
Could not write header for output file #0 (incorrect codec parameters ?): Experimental feature
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
    Last message repeated 1 times

C:\Users\Max\Documents\tiktok bot>

System Information OS: Windows 10 Pro 21H2 CPU: I7-5820K @ 4.80GHZ RAM: 24.00GB Python Version: 3.9 Node Version: 16.13.0

Seeking Help, I want to try it out.

emil314 commented 2 years ago

I've had the same problem and solved it kind of like in this thread changing lines 45 to 50 from video_creation/background.py as following:

with VideoFileClip("assets/mp4/background.mp4") as video:
        new = video.subclip(start_time, end_time)
        new.write_videofile("assets/mp4/clip.mp4")
LukaHietala commented 2 years ago

That should fix the issue.

TrueWLAN commented 2 years ago

Should, let me try

TrueWLAN commented 2 years ago

This Fix is Working @CallumIO @LukaHietala @elebumm, Please import this Fix into the Master Repository.