Open nikhiltree opened 1 year ago
Closing this issue as it's missing information for reproducability, like useful code samples or properly formatted error logs. Please use code-formatted text for code and logs, not screenshots.
We can reopen the issue once you've updated it. Please be aware you should always try to work with the latest master of MoviePy where possible, not the last PyPI release, which is quite old.
thanks i will update in proper format
please open my issue again i did formating stuff
I am also having a similar issue.
import moviepy.video.fx.all as vfx
from moviepy.editor import VideoFileClip, concatenate_videoclips
video_length = 20
video_file = "Primary\\Videos\\3.mp4"
Evideo = VideoFileClip(video_file)
x = vfx.time_mirror(Evideo)
Evideo = concatenate_videoclips([Evideo, x])
Evideo.write_videofile('output.mp4')
to write a video file plays normally first half and plays in reverse in second in 2nd half
Traceback (most recent call last):
File "d:\Video_generator\5_Facts\t.py", line 7, in <module>
x = vfx.time_mirror(Evideo)
^^^^^^^^^^^^^^^^^^^^^^^
File "<decorator-gen-89>", line 2, in time_mirror
File "C:\Users\devan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\moviepy\decorators.py", line 54, in requires_duration
return f(clip, *a, **k)
^^^^^^^^^^^^^^^^
File "<decorator-gen-88>", line 2, in time_mirror
File "C:\Users\devan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\moviepy\decorators.py", line 29, in apply_to_mask
newclip = f(clip, *a, **k)
^^^^^^^^^^^^^^^^
File "<decorator-gen-87>", line 2, in time_mirror
File "C:\Users\devan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\moviepy\decorators.py", line 41, in apply_to_audio
newclip = f(clip, *a, **k)
^^^^^^^^^^^^^^^^
File "C:\Users\devan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\moviepy\video\fx\time_mirror.py", line 13, in time_mirror
return self.fl_time(lambda t: self.duration - t, keep_duration=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\devan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\moviepy\Clip.py", line 187, in fl_time
return self.fl(lambda gf, t: gf(t_func(t)), apply_to,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\devan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\moviepy\Clip.py", line 136, in fl
newclip = self.set_make_frame(lambda t: fun(self.get_frame, t))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<decorator-gen-63>", line 2, in set_make_frame
File "C:\Users\devan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\moviepy\decorators.py", line 14, in outplace
f(newclip, *a, **k)
File "C:\Users\devan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\moviepy\video\VideoClip.py", line 644, in set_make_frame
self.size = self.get_frame(0).shape[:2][::-1]
^^^^^^^^^^^^^^^^^
File "<decorator-gen-13>", line 2, in get_frame
File "C:\Users\devan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\moviepy\decorators.py", line 89, in wrapper
return f(*new_a, **new_kw)
^^^^^^^^^^^^^^^^^^^
File "C:\Users\devan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\moviepy\Clip.py", line 93, in get_frame
return self.make_frame(t)
^^^^^^^^^^^^^^^^^^
File "C:\Users\devan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\moviepy\Clip.py", line 136, in <lambda>
newclip = self.set_make_frame(lambda t: fun(self.get_frame, t))
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\devan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\moviepy\Clip.py", line 187, in <lambda>
return self.fl(lambda gf, t: gf(t_func(t)), apply_to,
^^^^^^^^^^^^^
File "<decorator-gen-13>", line 2, in get_frame
File "C:\Users\devan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\moviepy\decorators.py", line 89, in wrapper
return f(*new_a, **new_kw)
^^^^^^^^^^^^^^^^^^^
File "C:\Users\devan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\moviepy\Clip.py", line 93, in get_frame
return self.make_frame(t)
^^^^^^^^^^^^^^^^^^
File "C:\Users\devan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\moviepy\video\io\VideoFileClip.py", line 113, in <lambda>
self.make_frame = lambda t: self.reader.get_frame(t)
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\devan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\moviepy\video\io\ffmpeg_reader.py", line 184, in get_frame
result = self.read_frame()
^^^^^^^^^^^^^^^^^
File "C:\Users\devan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\moviepy\video\io\ffmpeg_reader.py", line 133, in read_frame
raise IOError(("MoviePy error: failed to read the first frame of "
OSError: MoviePy error: failed to read the first frame of video file Primary\Videos\3.mp4. That might mean that the file is corrupted. That may also mean that you are using a deprecated version of FFMPEG. On Ubuntu/Debian for instance the version in the repos is deprecated. Please update to a recent version from the website.
Hello, @keikoro did u get any solution for that ?
Hello, @keikoro did u get any solution for that ?
Sorry, I didn't look into the issue, I only went through our tickets to tag them and pointed out missing info in the process.
@nikhiltree Pass the file path, not the URL of the video in VideoFileClip
.
if we want to pass the local path then we need to download the video from s3 bucket and we have kubernets so if we download it then it will create too much load in our instance
please here any body run this code on minkube and help me out to solve this error @keikoro
But in order to run this code you need to pass file path, it won’t work if you pass url of the video, you can download your video using requests
module or try a video from your local computer.
Additionally if you’re hosting your videos on s3 bucket and downloading videos will increase load, so why are you using s3 bucket when you can’t even download a video?
suppose if i have one user and user have the 1 video xyz.mp4 and i am creating 500 video from this xyz.mp4. Now imagine 500 users if i download this much video template in cluster that would be very costly time as well as resource so better options is whenever process required the video just call the url. we are using celery for maintaining task which is create the 500 videos that 500 videos user can download via s3 link
our concerns is why this library can't load video from s3 link that's right direction to think i guess
@nikhiltree I am facing same issue while working with EC2 (Ubuntu). The code works fine for Windows but I am not able to read video from URL in EC2. Any suggestions?
@nikhiltree, @qaixerabbas I am also facing a similar issue. What's stranger for me is that in my dev environment, I can create the VideoClip from an S3 URL. But in my production environment, I see the following error:
raise IOError(("MoviePy error: failed to read the duration of file %s.\n"
OSError: MoviePy error: failed to read the duration of file {url_here}.
Does anyone have any workarounds for this?
Firstly Sorry For Late Reply.
`from future import division
import logging import os import re import subprocess as sp import warnings
import numpy as np
from moviepy.compat import DEVNULL, PY3 from moviepy.config import get_setting # ffmpeg, ffmpeg.exe, etc... from moviepy.tools import cvsecs
is_GIF = False cmd = [get_setting("FFMPEG_BINARY", "-i", "link_s3"]
if is_GIF: cmd += ["-f", "null", "/dev/null"]
popen_params = {"bufsize": 10**5,"stdout": sp.PIPE,"stderr": sp.PIPE,"stdin": DEVNULL} if os.name == "nt": popen_params["creationflags"] = 0x08000000
proc = sp.Popen(cmd, **popen_params) (output, error) = proc.communicate() infos = error.decode('utf8') print(infos) `
Hi, thank you for the response! I tried running the script on my prod environment in Heroku. I ensured ffmpeg was installed via build pack. However, the duration doesn't show up in production. The duration DOES appear in my local dev environment. I tried setting the environment variable as well. Any other tips as to what could be going on here?
I see am currently you are facing an issue with a piece of code. If it's convenient for you, could we possibly arrange a meeting to discuss the problem in more detail? My availability is flexible, and I believe that a brief collaboration session would greatly expedite the resolution process.
If sharing the actual code poses any confidentiality concerns, you can certainly describe the relevant code snippets to provide context. Your insights would be valuable in helping me identify and rectify the issue.
hey @ashankv I downloaded the video and then use MoviePy for further processing. I used pythons's wget module to temporarily download video on server and then do processing. In my case I wrote a backend service on Linux so downloading the video was better option for me which is working perfectly fine. In my previous task I was writing a FastAPI application so I tried to read file from URL and I was not successful in production environment on Linux (EC2 Ubuntu).
Hi all, did anyone get any further with this?
I am experiencing the same or a similar issue. When I run moviepy code locally in my virtual environment, it will happily create an AudioFileClip
with a url as the file source, not a local file path. If I run in docker however it will not. I have a small example in this repo to demonstrate.
Does anyone know why this could be happening? Thanks
Repo: https://github.com/alifhughes/moviepy-example
EDIT: I believe it is soemthing to do with the different compiled versions of ffmpeg from Apple to Debian on the docker image. The easier way around it is to do, like everyone else, download the video and then process it. Curious to see if anyone can resolve it though
I have faced same issue. @alifhughes said downloading the video and then processing it can solve this issue and I am using firebase functions How can I download In that environment?
Any update on this, facing the same issue @alifhughes @ashankv @nikhiltree @qaixerabbas
It is still not working for us
Problem : Reading video in local and docker-compose file works fine but in minikube below issue occured
Expected Behavior
Actual Behavior
Specifications
Requirement.txt