Zulko / moviepy

Video editing with Python
https://zulko.github.io/moviepy/
MIT License
12.07k stars 1.51k forks source link

error: OpenCV(4.9.0) :-1: error: (-5:Bad argument) in function 'putText' #2105

Closed sugizo closed 4 months ago

sugizo commented 5 months ago

Expected Behavior

can work with opencv python module

Actual Behavior

not work with opencv and have an error

error                                     Traceback (most recent call last)
[<ipython-input-166-e96ac98275c5>](https://localhost:8080/#) in <cell line: 1>()
----> 1 video0 = video0.fl_image(tes)

8 frames
<decorator-gen-178> in set_make_frame(self, mf)

<decorator-gen-128> in get_frame(self, t)

[<ipython-input-164-e75c0cf2b061>](https://localhost:8080/#) in tes(image)
     90     color = (0, 0, 128)
     91     thickness = 2
---> 92     return cv2.putText(image, text, org, font, fontScale, color, thickness, cv2.LINE_AA, False)

error: OpenCV(4.9.0) :-1: error: (-5:Bad argument) in function 'putText'
> Overload resolution failed:
>  - img marked as output argument, but provided NumPy array marked as readonly
>  - Expected Ptr<cv::UMat> for argument 'img'

Steps to Reproduce the Problem

!wget -c https://cdn.creatomate.com/demo/mountains.mp4
pip install -U moviepy opencv-python
from moviepy.editor import *
import cv2
def tes(image):
    text = 'tes'
    font = cv2.FONT_HERSHEY_SIMPLEX
    org = (00, 185)
    fontScale = 1
    color = (0, 0, 128)
    thickness = 2
    return cv2.putText(image, text, org, font, fontScale, color, thickness, cv2.LINE_AA, False)
video0 = VideoFileClip("mountains.mp4")
video0 = video0.fl_image(tes)

Specifications

test opencv with the same python version and same google colab platform it's work well image

thanks and best regards

keikoro commented 4 months ago

Please don't post any screenshots of code, use code-formatted text instead.

keikoro commented 4 months ago

Also, as said in another issue, it appears you are reporting errors with (random) other libraries here, which I don't think is something anyone will be able to help you with.

It's unlikely that MoviePy is to blame for all these errors, otherwise there'd be more tickets which report the same. I'd suggest the problem lies with the platform or with how you import things. Don't do from moviepy.editor import * for a start, but only import what you need; it's possible that the imports are interfering with one another.

I'll close this and the other similar issues because I don't believe this is a problem with MoviePy per se. Please try the above suggestion and feel free to report back if it turns out it is.