3

I want to save a video into another file using different name. Thus, I have following codes to handle this question:

def process_image_1(image):
  img=mpimg.imread(image)
  return img;

Also, I have

output='output.mp4'
clip1 = VideoFileClip("Right.mp4")
clip = clip1.fl_image(process_image_1)
%time clip.write_videofile(output, audio=False)

However, I got the following error:

Object does not appear to be a 8-bit string path or a Python file-like object

I am not sure what's wrong with it, can someone tell me why?

user144600
  • 529
  • 2
  • 7
  • 18

1 Answers1

8

The fl_image function accepts an image function as parameter, so the parameter passed to the image function process_image_1 should be an image, but not the path to an image.

Remove the line img=mpimg.imread(image) and read the image file outside of the image function, e.g.

result = process_image(mpimg.imread(image))

and it shall work.

Foxan Ng
  • 6,883
  • 4
  • 34
  • 41