Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
KalvinThien opened this issue Oct 2, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@KalvinThien
Copy link

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.stepDictcurrentStep
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

@KalvinThien KalvinThien added the bug Something isn't working label Oct 2, 2023
@dey-d
Copy link

dey-d commented Dec 2, 2023

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

@chenfanfang
Copy link

+1

@alportblu
Copy link

alportblu commented Apr 16, 2024

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'])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants