def run(self): self.start_time = time.monotonic() if self.render_data.save_internally == True: frame_name = "frame" else: frame_name = self.render_data.frame_name rendered_frames_folder = ccrutils.rendered_frames_folder() # Delete old rendered frames for frame_file in os.listdir(rendered_frames_folder): file_path = os.path.join(rendered_frames_folder, frame_file) os.remove(file_path) if self.abort == True: return script_file = open(self.script_path) user_script = script_file.read() profile_file_path = mltprofiles.get_profile_file_path( self.profile_desc) editors_data_json = json.dumps( self.fluxity_plugin_edit_data["editors_list"] ) # See fluxity.FluxityContext.get_script_data() fluxity.render_frame_sequence(user_script, self.range_in, self.range_out, rendered_frames_folder, profile_file_path, self.frames_update, editors_data_json, True) render_length = self.range_out - self.range_in while len(os.listdir(rendered_frames_folder)) != render_length: if self.abort == True: return time.sleep(0.5) # Render video if self.render_data.do_video_render == True: # Render consumer args_vals_list = toolsencoding.get_args_vals_list_for_render_data( self.render_data) profile = mltprofiles.get_profile_for_index( self.render_data.profile_index) if self.render_data.save_internally == True: file_path = ccrutils.session_folder( ) + "/" + appconsts.CONTAINER_CLIP_VIDEO_CLIP_NAME + self.render_data.file_extension else: file_path = self.render_data.render_dir + "/" + self.render_data.file_name + self.render_data.file_extension consumer = renderconsumer.get_mlt_render_consumer( file_path, profile, args_vals_list) # Render producer num_part = str(1).zfill(5) frame_file = rendered_frames_folder + "/" + frame_name + "_" + num_part + ".png" resource_name_str = utils.get_img_seq_resource_name( frame_file, True) resource_path = rendered_frames_folder + "/" + resource_name_str producer = mlt.Producer(profile, str(resource_path)) frames_length = len(os.listdir(rendered_frames_folder)) self.render_player = renderconsumer.FileRenderPlayer( "", producer, consumer, 0, frames_length - 1) self.render_player.wait_for_producer_end_stop = False self.render_player.start() while self.render_player.stopped == False: self.abort_requested() if self.abort == True: self.render_player.shutdown() return fraction = self.render_player.get_render_fraction() self.video_render_update_callback(fraction) time.sleep(0.3) ccrutils.delete_rendered_frames() # Write out completed flag file. ccrutils.write_completed_message()
def run(self): self.start_time = time.monotonic() self.render_player = None self.frames_range_writer = None self.script_renderer = None if self.render_data.save_internally == True: frame_name = "frame" else: frame_name = self.render_data.frame_name clip_frames_folder = ccrutils.clip_frames_folder() rendered_frames_folder = ccrutils.rendered_frames_folder() profile = mltprofiles.get_profile(self.profile_desc) # Delete old clip frames for frame_file in os.listdir(clip_frames_folder): file_path = os.path.join(clip_frames_folder, frame_file) os.remove(file_path) # Delete old rendered frames for frame_file in os.listdir(rendered_frames_folder): file_path = os.path.join(rendered_frames_folder, frame_file) os.remove(file_path) self.frames_range_writer = gmicplayer.FramesRangeWriter( self.clip_path, self.frames_update, profile) self.frames_range_writer.write_frames(clip_frames_folder + "/", frame_name, self.range_in, self.range_out) if self.abort == True: return script_file = open(self.script_path) user_script = script_file.read() while len(os.listdir(clip_frames_folder)) != self.length: time.sleep(0.5) # Render frames with gmic script self.script_renderer = gmicplayer.FolderFramesScriptRenderer( user_script, clip_frames_folder, rendered_frames_folder + "/", frame_name, self.script_render_update_callback, self.script_render_output_callback, 10, False, # this is not useful until we get MLT to fin frames sequences not startin from 0001 0) self.script_renderer.write_frames() ccrutils.delete_clip_frames() if self.abort == True: return # Render video if self.render_data.do_video_render == True: # Render consumer args_vals_list = toolsencoding.get_args_vals_list_for_render_data( self.render_data) profile = mltprofiles.get_profile_for_index( self.render_data.profile_index) if self.render_data.save_internally == True: file_path = ccrutils.session_folder( ) + "/" + appconsts.CONTAINER_CLIP_VIDEO_CLIP_NAME + self.render_data.file_extension else: file_path = self.render_data.render_dir + "/" + self.render_data.file_name + self.render_data.file_extension consumer = renderconsumer.get_mlt_render_consumer( file_path, profile, args_vals_list) # Render producer frame_file = rendered_frames_folder + "/" + frame_name + "_0000.png" resource_name_str = utils.get_img_seq_resource_name( frame_file, True) resource_path = rendered_frames_folder + "/" + resource_name_str producer = mlt.Producer(profile, str(resource_path)) frames_length = len(os.listdir(rendered_frames_folder)) self.render_player = renderconsumer.FileRenderPlayer( "", producer, consumer, 0, frames_length - 1) self.render_player.wait_for_producer_end_stop = False self.render_player.start() while self.render_player.stopped == False: self.abort_requested() if self.abort == True: self.render_player.shutdown() return fraction = self.render_player.get_render_fraction() self.video_render_update_callback(fraction) time.sleep(0.3) ccrutils.delete_rendered_frames() # Write out completed flag file. ccrutils.write_completed_message()
def run(self): self.start_time = time.monotonic() args_vals_list = toolsencoding.get_args_vals_list_for_render_data( self.render_data) profile = mltprofiles.get_profile_for_index( self.render_data.profile_index) producer = mlt.Producer(profile, str(self.xml_file_path)) # Video clip consumer if self.render_data.do_video_render == True: if self.render_data.save_internally == True: file_path = ccrutils.session_folder( ) + "/" + appconsts.CONTAINER_CLIP_VIDEO_CLIP_NAME + self.render_data.file_extension else: file_path = self.render_data.render_dir + "/" + self.render_data.file_name + self.render_data.file_extension consumer = renderconsumer.get_mlt_render_consumer( file_path, profile, args_vals_list) ccrutils.delete_rendered_frames( ) # in case we switched from img seq consumer we can now delete those frames to save space # img seq consumer else: # Image sequence gets project profile project_profile = mltprofiles.get_profile(self.profile_desc) if self.render_data.save_internally == True: frame_name = "frame" else: frame_name = self.render_data.frame_name render_path = ccrutils.rendered_frames_folder( ) + frame_name + "_%04d." + "png" consumer = mlt.Consumer(project_profile, "avformat", str(render_path)) consumer.set("real_time", -1) consumer.set("rescale", "bicubic") consumer.set("vcodec", "png") self.render_player = renderconsumer.FileRenderPlayer( "", producer, consumer, self.range_in, self.range_out) self.render_player.wait_for_producer_end_stop = False self.render_player.start() while self.render_player.stopped == False: self.abort_requested() if self.abort == True: self.render_player.shutdown() return fraction = self.render_player.get_render_fraction() self.render_update_callback(fraction) time.sleep(0.3) # Write out completed flag file. ccrutils.write_completed_message()