本文整理汇总了Python中moviepy.editor.VideoFileClip.save_frame方法的典型用法代码示例。如果您正苦于以下问题:Python VideoFileClip.save_frame方法的具体用法?Python VideoFileClip.save_frame怎么用?Python VideoFileClip.save_frame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类moviepy.editor.VideoFileClip
的用法示例。
在下文中一共展示了VideoFileClip.save_frame方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_video_thumbnails
# 需要导入模块: from moviepy.editor import VideoFileClip [as 别名]
# 或者: from moviepy.editor.VideoFileClip import save_frame [as 别名]
def create_video_thumbnails(repo, file_id, path, size, thumbnail_file, file_size):
t1 = timeit.default_timer()
token = seafile_api.get_fileserver_access_token(repo.id,
file_id, 'view', '', use_onetime=False)
if not token:
return (False, 500)
inner_path = gen_inner_file_get_url(token, os.path.basename(path))
clip = VideoFileClip(inner_path)
tmp_path = str(os.path.join(tempfile.gettempdir(), '%s.png' % file_id[:8]))
clip.save_frame(tmp_path, t=THUMBNAIL_VIDEO_FRAME_TIME)
t2 = timeit.default_timer()
logger.debug('Create thumbnail of [%s](size: %s) takes: %s' % (path, file_size, (t2 - t1)))
try:
ret = _create_thumbnail_common(tmp_path, thumbnail_file, size)
os.unlink(tmp_path)
return ret
except Exception as e:
logger.error(e)
os.unlink(tmp_path)
return (False, 500)
示例2: decrypt_video
# 需要导入模块: from moviepy.editor import VideoFileClip [as 别名]
# 或者: from moviepy.editor.VideoFileClip import save_frame [as 别名]
def decrypt_video(filename, t0=56):
vid = VideoFileClip(filename)
vid.save_frame("frame.png", t=t0+0.05)
img = Image.open("frame.png").convert(mode='RGB')
msg = stepic.decode(img)
return msg
示例3: video
# 需要导入模块: from moviepy.editor import VideoFileClip [as 别名]
# 或者: from moviepy.editor.VideoFileClip import save_frame [as 别名]
def video(filename, username, t0):
# Orignal Video
original = VideoFileClip("static/videos/"+filename+".mp4")
first_half = VideoFileClip("static/videos/"+filename+".mp4").subclip(0, t0)
second_half = VideoFileClip("static/videos/"+filename+".mp4").subclip(t0+1, original.duration)
original.save_frame("static/videos/frame.png", t=t0)
img = Image.open("static/videos/frame.png").convert(mode='RGB')
stepic.encode_inplace(img, username)
msg = stepic.decode(img)
print(msg)
img.save("static/videos/frame.png")
encoded_clip = ImageClip('static/videos/frame.png', duration=1)
new_mov = CompositeVideoClip([first_half.set_start(0),
encoded_clip.set_start(t0),
second_half.set_start(t0+1)])
# Write the result to a file (many options available !)
new_mov.write_videofile("static/"+username+"_"+filename+".avi", codec='png')