0

I'm struggling with my converter from mp4 to gif.

Its basically been put together from imageio website and YouTube, but cant get it to work.

#[python converter.py]
import imageio
import os

clip = os.path.abspath('six.mp4')

def gifMaker(inputPath,targetFormat):
    outputPath = os.path.splitext(inputPath)[0] + (targetFormat)
    
    print(f'converting {inputPath} \n to {outputPath}')
     
    reader = imageio.get_reader(inputPath)
    fps = reader.get_meta_data()['fps']
    
    writer = imageio.get_reader(outputPath, fps=fps)
    
    for frames in reader:
        writer.append_data(frames)
        print (f'frame {frames}')
    print('Klart')
    writer.close()

gifMaker (clip, '.gif')
Henry Ecker
  • 34,399
  • 18
  • 41
  • 57

1 Answers1

0

In the line where you are creating "writer":

writer = imageio.get_reader(outputPath, fps=fps)

Just change the get_reader call for get_writer

writer = imageio.get_writer(outputPath, fps=fps)

That should be enough to make it work.

Mr K.
  • 1,064
  • 3
  • 19
  • 22