elebumm / RedditVideoMakerBot

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

IndexError: list index out of range #1006

Closed LiamGallagher737 closed 1 year ago

LiamGallagher737 commented 2 years ago

Describe the bug Sometimes when it gets to the Creating the final video 🎥 stage it throws the following error, this doesn't happen on most posts but on this reddit post it happens every time it runs

Traceback (most recent call last):
  File "C:\Users\Liam\AppData\Local\Programs\Python\Python310\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 285, in ffmpeg_parse_infos
    line = [l for l in lines if keyword in l][index]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Liam\Desktop\RedditVideoMakerBot-2.3\main.py", line 65, in <module>
    run_many(config["settings"]["times_to_run"])
  File "C:\Users\Liam\Desktop\RedditVideoMakerBot-2.3\main.py", line 56, in run_many
    main()
  File "C:\Users\Liam\Desktop\RedditVideoMakerBot-2.3\main.py", line 48, in main
    make_final_video(number_of_comments, length, reddit_object, bg_config)
  File "C:\Users\Liam\Desktop\RedditVideoMakerBot-2.3\video_creation\final_video.py", line 75, in make_final_video    audio_clips = [AudioFileClip(f"assets/temp/mp3/{i}.mp3") for i in range(number_of_clips)]
  File "C:\Users\Liam\Desktop\RedditVideoMakerBot-2.3\video_creation\final_video.py", line 75, in <listcomp>      
    audio_clips = [AudioFileClip(f"assets/temp/mp3/{i}.mp3") for i in range(number_of_clips)]
  File "C:\Users\Liam\AppData\Local\Programs\Python\Python310\lib\site-packages\moviepy\audio\io\AudioFileClip.py", line 70, in __init__
    self.reader = FFMPEG_AudioReader(filename, fps=fps, nbytes=nbytes,
  File "C:\Users\Liam\AppData\Local\Programs\Python\Python310\lib\site-packages\moviepy\audio\io\readers.py", line 51, in __init__
    infos = ffmpeg_parse_infos(filename)
  File "C:\Users\Liam\AppData\Local\Programs\Python\Python310\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 289, in ffmpeg_parse_infos
    raise IOError(("MoviePy error: failed to read the duration of file %s.\n"
OSError: MoviePy error: failed to read the duration of file assets/temp/mp3/2.mp3.
Here are the file infos returned by ffmpeg:

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
[mp3 @ 00000172ee7a8d00] Format mp3 detected only with low score of 1, misdetection possible!
[mp3 @ 00000172ee7a8d00] Failed to read frame size: Could not seek to 1026.
assets/temp/mp3/2.mp3: Invalid argument

To Reproduce Run the bot for this post

System (please complete the following information):

micziz commented 2 years ago

It fails to know how long the mp3 is. This is used to know how long the final video will be. I really don't know how to help you. I recommend you use another thread.

JasonLovesDoggo commented 2 years ago

What version are you on (It is one of the first things the bot prints)

puttyq commented 2 years ago

Check your Python version. I suspect you are running something older than the required 3.9+. That was my issue when running on Python 3.8

LiamGallagher737 commented 2 years ago

Python Version is 3.10.5 App version is 2.3

puttyq commented 2 years ago

Spoke too soon @LiamGallagher737 - I also ran into the error again. App Version 2.3 Python Version 3.10.4

OSError: MoviePy error: failed to read the duration of file assets/temp/mp3/2.mp3.

I can confirm that those post you linked has the same result for me.

efa2d19 commented 2 years ago

I saw something similar when TTS returned blank file Maybe this helps

JasonLovesDoggo commented 2 years ago

Will test tomorrow

ShadowUTube commented 2 years ago

@LiamGallagher737 @JasonLovesDoggo @puttyq Did one of you find the fix for this

MullerTM commented 2 years ago

Still no fix???. I have the exact same problem when using TikTok's TTS