Beispiel #1
0
    def run(self):
        self.start_time = time.monotonic()

        self.render_player = None
        self.frames_range_writer = None

        self.abort = False
        self.script_renderer = None

        frame_name = "frame"
        profile = mltprofiles.get_profile(self.profile_desc)

        # Delete old preview frames
        for frame_file in os.listdir(_clip_frames_folder):
            file_path = os.path.join(_clip_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()
        print(user_script)
        while len(os.listdir(_clip_frames_folder)) != self.length:
            print("WAITING")
            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,
            nice=10,
            re_render_existing=False)
        self.script_renderer.write_frames()

        # Write out completed flag file.
        completed_msg_file = _session_folder + "/" + COMPLETED_MSG_FILE
        script_text = "##completed##"  # let's put something in here
        with atomicfile.AtomicFileWriter(completed_msg_file, "w") as afw:
            script_file = afw.get_file()
            script_file.write(script_text)
Beispiel #2
0
    def run(self):
        self.render_player = None
        self.frames_range_writer = None

        self.abort = False
        self.script_renderer = None

        frame_name = "frame"
        profile = mltprofiles.get_profile(self.profile_desc)

        # Delete old preview frames
        for frame_file in os.listdir(_clip_frames_folder):
            file_path = os.path.join(_clip_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()
        print(user_script)
        while len(os.listdir(_clip_frames_folder)) != self.length:
            print("WAITING")
            time.sleep(0.5)

        # Render frames with gmic script
        self.script_renderer = gmicplayer.FolderFramesScriptRenderer(
            user_script, _clip_frames_folder, _session_folder + "/",
            frame_name, self.script_render_update_callback,
            self.script_render_output_callback)
        self.script_renderer.write_frames()

        self.dbus_obj.shutdown()
        """
Beispiel #3
0
    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()