RayVentura / ShortGPT

🚀🎬 ShortGPT - Experimental AI framework for youtube shorts / tiktok channel automation
https://shortx.ai/?ref=sgpt
MIT License
5.77k stars 731 forks source link

🐛 [Bug]: raise IOError(("MoviePy error: failed to read the duration of file %s.\n" #108

Open KalvinThien opened 1 year ago

KalvinThien commented 1 year ago

What happened?

OSError: MoviePy error: failed to read the duration of file https://rr4---sn-npoeeney.googlevideo.com/videoplayback?expire=1696251991&ei=92saZY_aBf7ez7sPscOnuAI&ip=159.223.53.224&id=o-AIzOiwe7IlswBA6515Fj_fxzPS8k-mDtTEtNT44YlOUJ&itag=248&source=youtube&requiressl=yes&mh=XS&mm=31%2C29&mn=sn-npoeeney%2Csn-npoe7nsd&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=156250&vprv=1&svpuc=1&mime=video%2Fwebm&gir=yes&clen=121959&dur=8.099&lmt=1653637154019851&mt=1696230104&fvip=4&keepalive=yes&fexp=24007246&beids=24350017&c=IOS&txp=5316224&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Csvpuc%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRQIgMfLjJ6WeM2IaJiMZeqFkpcgVL9NSQvDKkb4XzJdqEPICIQC1ue86w6qeRlSpfS0BX7xvQaqkVsCYLLFoc_Y5hhXpog%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRQIgH8sQInuqOvzzuYsd-TBQygoS-RqcdEfSSwUu1cqqjg8CIQC-NR-Z3QcZ9HDc1X6uu6m-7b9DZ8KtFO0c8zWRm_h5Zg%3D%3D. Here are the file infos returned by ffmpeg: ffmpeg version 4.2.2-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2019 the FFmpeg developers built with gcc 8 (Debian 8.3.0-6) configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg 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 Traceback: File "/usr/local/lib/python3.10/dist-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script exec(code, module.dict) File "/home/main/main.py", line 128, in app_runner.run() File "/home/main/main.py", line 95, in run Auto_Fact.app() File "/home/main/Auto_Fact.py", line 56, in app for step_num, step_logs in enumerate(content_engine.makeContent(), start=1): # Bắt đầu từ bước thứ 3 File "/usr/local/lib/python3.10/dist-packages/shortGPT/engine/abstract_content_engine.py", line 74, in makeContent self.stepDict[currentStep]() File "/usr/local/lib/python3.10/dist-packages/shortGPT/engine/content_short_engine.py", line 150, in _editAndRenderShort videoEditor.renderVideo(outputPath, logger= self.logger if self.logger is not self.default_logger else None) File "/usr/local/lib/python3.10/dist-packages/shortGPT/editing_framework/editing_engine.py", line 97, in renderVideo engine.generate_video(self.schema, outputPath, logger=logger) File "/usr/local/lib/python3.10/dist-packages/shortGPT/editing_framework/core_editing_engine.py", line 53, in generate_video clip = self.process_video_asset(asset) File "/usr/local/lib/python3.10/dist-packages/shortGPT/editing_framework/core_editing_engine.py", line 200, in process_video_asset clip = VideoFileClip(**params) File "/usr/local/lib/python3.10/dist-packages/moviepy/video/io/VideoFileClip.py", line 88, in init self.reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt, File "/usr/local/lib/python3.10/dist-packages/moviepy/video/io/ffmpeg_reader.py", line 35, in init infos = ffmpeg_parse_infos(filename, print_infos, check_duration, File "/usr/local/lib/python3.10/dist-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"

What type of browser are you seeing the problem on?

Microsoft Edge

What type of Operating System are you seeing the problem on?

Linux

Python Version

python 3.10

Application Version

newest

Expected Behavior

when the code works in the PC everything is good, works stably However, when running on Ubuntu, the error .

I followed this guide https://docs.shortgpt.ai/docs/facts-short-engine

thanks

Error Message

OSError: MoviePy error: failed to read the duration of file https://rr4---sn-npoeeney.googlevideo.com/videoplayback?expire=1696251991&ei=92saZY_aBf7ez7sPscOnuAI&ip=159.223.53.224&id=o-AIzOiwe7IlswBA6515Fj_fxzPS8k-mDtTEtNT44YlOUJ&itag=248&source=youtube&requiressl=yes&mh=XS&mm=31%2C29&mn=sn-npoeeney%2Csn-npoe7nsd&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=156250&vprv=1&svpuc=1&mime=video%2Fwebm&gir=yes&clen=121959&dur=8.099&lmt=1653637154019851&mt=1696230104&fvip=4&keepalive=yes&fexp=24007246&beids=24350017&c=IOS&txp=5316224&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Csvpuc%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRQIgMfLjJ6WeM2IaJiMZeqFkpcgVL9NSQvDKkb4XzJdqEPICIQC1ue86w6qeRlSpfS0BX7xvQaqkVsCYLLFoc_Y5hhXpog%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRQIgH8sQInuqOvzzuYsd-TBQygoS-RqcdEfSSwUu1cqqjg8CIQC-NR-Z3QcZ9HDc1X6uu6m-7b9DZ8KtFO0c8zWRm_h5Zg%3D%3D. Here are the file infos returned by ffmpeg: ffmpeg version 4.2.2-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2019 the FFmpeg developers built with gcc 8 (Debian 8.3.0-6) configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg 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
Traceback:
File "/usr/local/lib/python3.10/dist-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script
    exec(code, module.__dict__)
File "/home/main/main.py", line 128, in <module>
    app_runner.run()
File "/home/main/main.py", line 95, in run
    Auto_Fact.app()
File "/home/main/Auto_Fact.py", line 56, in app
    for step_num, step_logs in enumerate(content_engine.makeContent(), start=1): # Bắt đầu từ bước thứ 3
File "/usr/local/lib/python3.10/dist-packages/shortGPT/engine/abstract_content_engine.py", line 74, in makeContent
    self.stepDict[currentStep]()
File "/usr/local/lib/python3.10/dist-packages/shortGPT/engine/content_short_engine.py", line 150, in _editAndRenderShort
    videoEditor.renderVideo(outputPath, logger= self.logger if self.logger is not self.default_logger else None)
File "/usr/local/lib/python3.10/dist-packages/shortGPT/editing_framework/editing_engine.py", line 97, in renderVideo
    engine.generate_video(self.schema, outputPath, logger=logger)
File "/usr/local/lib/python3.10/dist-packages/shortGPT/editing_framework/core_editing_engine.py", line 53, in generate_video
    clip = self.process_video_asset(asset)
File "/usr/local/lib/python3.10/dist-packages/shortGPT/editing_framework/core_editing_engine.py", line 200, in process_video_asset
    clip = VideoFileClip(**params)
File "/usr/local/lib/python3.10/dist-packages/moviepy/video/io/VideoFileClip.py", line 88, in __init__
    self.reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt,
File "/usr/local/lib/python3.10/dist-packages/moviepy/video/io/ffmpeg_reader.py", line 35, in __init__
    infos = ffmpeg_parse_infos(filename, print_infos, check_duration,
File "/usr/local/lib/python3.10/dist-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"

Code to produce this issue.

No response

Screenshots/Assets/Relevant links

No response

dey-d commented 11 months ago

I'm getting this error, did you figure it out?

chenfanfang commented 10 months ago

+1

alportblu commented 6 months ago

I had the same issue and it was related to https url to vimeo. I temporarily fixed this with the following code that downloaded the video file to a temporary file on line 179 of core_editing_engine.py: ` def process_video_asset(self, asset: Dict[str, Any]) -> VideoFileClip:

    params = {
        'filename': asset['parameters']['url']
    }
    if 'audio' in asset['parameters']:
        params['audio'] = asset['parameters']['audio']
    #Check url is https then download file to temp file first
    if params['filename'].startswith('https'):
        import requests
        import tempfile
        temp_file = tempfile.NamedTemporaryFile(delete=False)
        temp_file.write(requests.get(params['filename']).content)
        params['filename'] = temp_file.name
        clip = VideoFileClip(**params)
        temp_file.close()
    else:
        clip = VideoFileClip(**params)
    return self.process_common_visual_actions(clip, asset['actions'])