本文整理汇总了Python中moviepy.editor.VideoFileClip.fl_time方法的典型用法代码示例。如果您正苦于以下问题:Python VideoFileClip.fl_time方法的具体用法?Python VideoFileClip.fl_time怎么用?Python VideoFileClip.fl_time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类moviepy.editor.VideoFileClip
的用法示例。
在下文中一共展示了VideoFileClip.fl_time方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: of
# 需要导入模块: from moviepy.editor import VideoFileClip [as 别名]
# 或者: from moviepy.editor.VideoFileClip import fl_time [as 别名]
#------------------------------------------------------------------------
# Transform into pairs of (origin_offset, destination_offset)
#------------------------------------------------------------------------
brightnesses = dict([ ("%.2f" % (index / clip.fps), value[0]) for index, value in enumerate(brightnesses) ])
print "Found %f frames" % (clip.fps * clip.duration)
#------------------------------------------------------------------------
# Filter function.
# Need two cases, for video (scalar offsets) and audio (arrays).
#------------------------------------------------------------------------
def remap_time(t):
try:
t0 = t[0]
t1 = brightnesses["%.2f" % t0]
t += (t1 - t0)
except:
try:
t0 = t
t1 = brightnesses["%.2f" % t0]
t += (t1 - t0)
except Exception, e:
print "Exception when reordering: %s" % e
sys.exit(1)
return t
#------------------------------------------------------------------------
# Process the clip.
#------------------------------------------------------------------------
clip_sorted = clip.fl_time(remap_time, apply_to=['mask', 'audio'], keep_duration=True)
clip_sorted.write_videofile(args.output, fps = clip.fps, write_logfile = True, audio_bufsize = int(44100.0 / clip.fps))