Zulko / moviepy

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

AttributeError: 'numpy.ndarray' object has no attribute 'read' #2103

Open sugizo opened 5 months ago

sugizo commented 5 months ago

Expected Behavior

can work with fimage python module

Actual Behavior

not work with fimage and have an error

AttributeError                            Traceback (most recent call last)
[/usr/local/lib/python3.10/dist-packages/PIL/Image.py](https://localhost:8080/#) in open(fp, mode, formats)
   2978     try:
-> 2979         fp.seek(0)
   2980     except (AttributeError, io.UnsupportedOperation):

AttributeError: 'numpy.ndarray' object has no attribute 'seek'

During handling of the above exception, another exception occurred:

AttributeError                            Traceback (most recent call last)
11 frames
<decorator-gen-178> in set_make_frame(self, mf)

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

[/usr/local/lib/python3.10/dist-packages/PIL/Image.py](https://localhost:8080/#) in open(fp, mode, formats)
   2979         fp.seek(0)
   2980     except (AttributeError, io.UnsupportedOperation):
-> 2981         fp = io.BytesIO(fp.read())
   2982         exclusive_fp = True
   2983 

AttributeError: 'numpy.ndarray' object has no attribute 'read'

Steps to Reproduce the Problem

!wget -c https://cdn.creatomate.com/demo/mountains.mp4
pip install -U moviepy fimage
from moviepy.editor import *
from fimage import FImage
from fimage.filters import *
from fimage.presets import *
def tes(image):
    img = FImage(image)
    return img.apply(Sepia(90) )
video0 = VideoFileClip("mountains.mp4")
video0 = video0.fl_image(tes)

Specifications

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

thanks and best regards

sugizo commented 5 months ago

trying to use pillow arrary but get the same result code

import numpy as np
from PIL import Image

def tes(image):
    img = Image.fromarray(image)
    im = FImage(img)
    im.apply(Sepia(90) )
    return np.array(im)

video0 = VideoFileClip("mountains.mp4")
video0 = video0.fl_image(tes)

result

AttributeError                            Traceback (most recent call last)
[<ipython-input-7-a86f884d4715>](https://localhost:8080/#) in <cell line: 8>()
      6 
      7 video0 = VideoFileClip("mountains.mp4")
----> 8 video0 = video0.fl_image(tes)

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

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

[/usr/local/lib/python3.10/dist-packages/PIL/Image.py](https://localhost:8080/#) in __getattr__(self, name)
    544             )
    545             return self._category
--> 546         raise AttributeError(name)
    547 
    548     @property

AttributeError: read

thanks and best regards