【问题标题】:mp4 to gif converter failing to producemp4 到 gif 转换器无法生成
【发布时间】:2021-12-30 15:49:43
【问题描述】:

我正在努力使用从 mp4 到 gif 的转换器。

它基本上是从imageio网站和YouTube放在一起的,但不能让它工作。

#[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')

【问题讨论】:

  • writer 变量上的错字?

标签: python gif mp4 converters python-imageio


【解决方案1】:

在您创建“作家”的行中:

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

只需将 get_reader 调用更改为 get_writer

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

这应该足以让它发挥作用。

【讨论】:

    猜你喜欢
    • 2015-02-08
    • 1970-01-01
    • 2021-06-30
    • 2017-04-05
    • 1970-01-01
    • 2012-10-18
    • 2018-11-20
    • 2015-10-25
    • 2015-01-15
    相关资源
    最近更新 更多