本文整理匯總了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))