本文整理汇总了Python中moviepy.editor.VideoFileClip.set_fps方法的典型用法代码示例。如果您正苦于以下问题:Python VideoFileClip.set_fps方法的具体用法?Python VideoFileClip.set_fps怎么用?Python VideoFileClip.set_fps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类moviepy.editor.VideoFileClip
的用法示例。
在下文中一共展示了VideoFileClip.set_fps方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_movie_dataset
# 需要导入模块: from moviepy.editor import VideoFileClip [as 别名]
# 或者: from moviepy.editor.VideoFileClip import set_fps [as 别名]
def create_movie_dataset(movie_path, target_folder):
if not os.path.isdir(target_folder): os.makedirs(target_folder)
video = VideoFileClip(movie_path)
num_frames = int(video.fps * video.duration)
video = video.set_fps(1).set_duration(num_frames).resize(0.5)
first_frame = 650
num_cpus = multiprocessing.cpu_count()
saved_frames = set(map(lambda x: int(x) if x else 0, map(lambda f: ''.join(x for x in f if x.isdigit()), os.listdir(target_folder))))
num_done = len(saved_frames)
if num_done == 0:
offsets = np.random.randint(0, 10, num_frames - first_frame - 9)
offset_file = os.path.join(target_folder, 'offsets.npz')
np.savez_compressed(offset_file, offsets=offsets)
frames_per_process = (num_frames - first_frame) / num_cpus
for i in xrange(num_cpus):
start_i = i * frames_per_process + first_frame
end_i = num_frames if i == num_cpus - 1 else start_i + frames_per_process
print start_i, end_i
multiprocessing.Process(
target=create_movie_process,
args=(video, target_folder, start_i, end_i, first_frame, i, saved_frames)
).start()
return True