我正在用Python开发一个从HTML文件创建视频的程序。 HTML文件可能包含一个动画GIF,我需要在最后的视频中保留动画。在
受以下GitHub要点中提供的方法的启发,我已经成功地从gifhub中提取了每一帧:
https://gist.github.com/revolunet/848913
import os from PIL import Image def extractFrames(inGif, outFolder): frame = Image.open(inGif) nframes = 0 while frame: frame.save( '%s/%s-%s.gif' % (outFolder, os.path.basename(inGif), nframes ) , 'GIF') nframes += 1 try: frame.seek( nframes ) except EOFError: break; return True extractFrames('ban_ccccccccccc.gif', 'output')
我用这些帧替换了HTML中的GIF源代码,并使用PhantomJS生成了最终视频的所有帧。在
现在,我需要获得源GIF文件中每个帧的持续时间,以便在视频的相应帧中重现它。在
我在Python中找不到实现这一点的方法。在
目前没有回答
相关问题 更多 >
编程相关推荐