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