rotemtzaban / STIT

MIT License
1.2k stars 170 forks source link

ValueError: Image must be a numpy array. #7

Closed onefish51 closed 2 years ago

onefish51 commented 2 years ago
File "edit_video.py", line 137, in _main
    imageio.mimwrite(os.path.join(folder_path, 'out.mp4'), frames, fps=18, output_params=['-vf', 'fps=25'])
  File "/opt/conda/lib/python3.8/site-packages/imageio/core/functions.py", line 338, in mimwrite
    raise ValueError('Image must be a numpy array.')

imageio.mimwrite(uri, ims, format=None, **kwargs) Write multiple images to the specified file. Parameters ... ims [sequence of numpy arrays] The image data. Each array must be NxM, NxMx3 or NxMx4.

So there is something wrong.

johndpope commented 2 years ago

what happens if you print frames ? it seems like something is going wrong upstream...

onefish51 commented 2 years ago

from add_texts_to_image_vertical and video_frames[folder_name].append(video_frame), it's list(PIL.Image.Image) when I add out_image = np.array(out_image) in utils/edit_utils.py/def add_texts_to_image_vertical(texts, pivot_images) before return out_image, a new error occurred

File "edit_video.py", line 54, in main
    _main(**config, config=config)
  File "edit_video.py", line 137, in _main
    imageio.mimwrite(os.path.join(folder_path, 'out.mp4'), frames, fps=18, output_params=['-vf', 'fps=25'])
  File "/opt/conda/lib/python3.8/site-packages/imageio/core/functions.py", line 341, in mimwrite
    writer.append_data(im)
  File "/opt/conda/lib/python3.8/site-packages/imageio/core/format.py", line 492, in append_data
    return self._append_data(im, total_meta)
  File "/opt/conda/lib/python3.8/site-packages/imageio/plugins/ffmpeg.py", line 666, in _append_data
    raise IOError(msg)
OSError: [Errno 32] Broken pipe

and ffmpeg version 4.3 Copyright (c) 2000-2020 the FFmpeg developers imageio in /opt/conda/lib/python3.8/site-packages (2.3.0) imageio-ffmpeg==0.4.2 in /opt/conda/lib/python3.8/site-packages (0.4.2)

rotemtzaban commented 2 years ago

@onefish51 I would guess that both issues are version issues, can you try to upgrade imageio and imageio-ffmpeg? The versions that I use are: imageio==2.16.0 imageio-ffmpeg==0.4.5

rotemtzaban commented 2 years ago

As for the numpy array/PIL image, I will test if it works well with numpy arrays and update it.

onefish51 commented 2 years ago

Successfully installed imageio-2.16.0 Successfully installed imageio-ffmpeg-0.4.5

and the error fixed! thanks!