예제 #1
0
 def __init__(self, clip_path, profile_desc):
     threading.Thread.__init__(self)
     self.clip_path = clip_path
     profile = mltprofiles.get_profile(profile_desc)
     self.temp_clip = self._get_temp_producer(clip_path, profile)
     self.file_cache_path = _get_levels_file_path(clip_path, profile)
     self.last_rendered_frame = 0
예제 #2
0
 def __init__(self, clip_path, profile_desc):
     threading.Thread.__init__(self)
     self.clip_path = clip_path
     profile = mltprofiles.get_profile(profile_desc)
     self.temp_clip = self._get_temp_producer(clip_path, profile)
     self.file_cache_path =_get_levels_file_path(clip_path, profile)
     self.last_rendered_frame = 0
예제 #3
0
    def _get_temp_producer(self, clip_path, profile_desc):
        profile = mltprofiles.get_profile(profile_desc)
        temp_producer = mlt.Producer(profile, str(clip_path))
        channels = mlt.Filter(profile, "audiochannels")
        converter = mlt.Filter(profile, "audioconvert")
        self.levels = mlt.Filter(profile, "audiolevel")
        temp_producer.attach(channels)
        temp_producer.attach(converter)
        temp_producer.attach(self.levels)
        temp_producer.path = clip_path
        self.clip_media_length = temp_producer.get_length()

        return temp_producer
예제 #4
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)
    def __init__(self, dbus_service, sequence_xml_path, segments, profile_name):
        threading.Thread.__init__(self)
        
        self.dbus_service = dbus_service
        self.sequence_xml_path = sequence_xml_path
        self.render_folder = os.path.dirname(sequence_xml_path)
        self.current_render_file_path = None
        self.profile = mltprofiles.get_profile(profile_name)
        self.segments = segments
        self.completed_segments =  ["nothing"]
        self.render_complete = False
        self.render_thread = None

        self.aborted = False
def main():
    # Set paths.
    root_path = sys.argv[3]
    respaths.set_paths(root_path)

    try:
        editorstate.mlt_version = mlt.LIBMLT_VERSION
    except:
        editorstate.mlt_version = "0.0.99"  # magic string for "not found"

    # Set folders paths
    userfolders.init()

    # Load editor prefs and list of recent projects
    editorpersistance.load()

    # Init translations module with translations data
    translations.init_languages()
    translations.load_filters_translations()
    mlttransitions.init_module()

    repo = mlt.Factory().init()
    processutils.prepare_mlt_repo(repo)

    # Set numeric locale to use "." as radix, MLT initilizes this to OS locale and this causes bugs
    locale.setlocale(locale.LC_NUMERIC, 'C')

    # Check for codecs and formats on the system
    mltenv.check_available_features(repo)
    renderconsumer.load_render_profiles()

    # Load filter and compositor descriptions from xml files.
    mltfilters.load_filters_xml(mltenv.services)
    mlttransitions.load_compositors_xml(mltenv.transitions)

    # Create list of available mlt profiles
    mltprofiles.load_profile_list()

    profile_desc = sys.argv[2]
    profile = mltprofiles.get_profile(profile_desc)

    files_paths = sys.argv[1]
    files_paths = files_paths.lstrip(FILE_SEPARATOR)

    files = files_paths.split(FILE_SEPARATOR)

    for f in files:
        t = WaveformCreator(f, profile_desc)
        t.start()
        t.join()
예제 #7
0
    def run(self):
        self.start_time = time.monotonic()

        profile = mltprofiles.get_profile(self.profile_desc)
        motion_producer = mlt.Producer(
            profile, None,
            str("timewarp:" + str(self.speed) + ":" + str(self.source_path)))

        # Create tractor and track to get right length
        tractor = mlt.Tractor()
        multitrack = tractor.multitrack()
        track0 = mlt.Playlist()
        multitrack.connect(track0, 0)
        track0.insert(motion_producer, 0, 0, motion_producer.get_length() - 1)

        consumer = renderconsumer.get_render_consumer_for_encoding_and_quality(
            self.write_file, profile, self.encoding_option_index,
            self.quality_option_index)

        # start and end frames, renderer stop behaviour
        start_frame = self.start_frame
        end_frame = self.end_frame
        wait_for_producer_stop = True
        if self.render_full_range == False:
            wait_for_producer_stop = False  # consumer wont stop automatically and needs to stopped explicitly

        # Launch render
        self.render_player = renderconsumer.FileRenderPlayer(
            self.write_file, tractor, consumer, start_frame, end_frame)
        self.render_player.wait_for_producer_end_stop = False
        self.render_player.start()

        while self.render_player.stopped == False:

            self.check_abort_requested()

            if self.abort == True:
                self.render_player.shutdown()
                return

            fraction = self.render_player.get_render_fraction()
            self.render_update(fraction)

            time.sleep(0.3)

        # Write out completed flag file.
        ccrutils.write_completed_message()
예제 #8
0
def main():
    # Set paths.
    root_path = sys.argv[3]
    respaths.set_paths(root_path)

    try:
        editorstate.mlt_version = mlt.LIBMLT_VERSION
    except:
        editorstate.mlt_version = "0.0.99" # magic string for "not found"
        
    # Load editor prefs and list of recent projects
    editorpersistance.load()
    
    # Init translations module with translations data
    translations.init_languages()
    translations.load_filters_translations()
    mlttransitions.init_module()

    repo = mlt.Factory().init()

    # Set numeric locale to use "." as radix, MLT initilizes this to OS locale and this causes bugs 
    locale.setlocale(locale.LC_NUMERIC, 'C')

    # Check for codecs and formats on the system
    mltenv.check_available_features(repo)
    renderconsumer.load_render_profiles()

    # Load filter and compositor descriptions from xml files.
    mltfilters.load_filters_xml(mltenv.services)
    mlttransitions.load_compositors_xml(mltenv.transitions)

    # Create list of available mlt profiles
    mltprofiles.load_profile_list()

    profile_desc = sys.argv[2]
    profile = mltprofiles.get_profile(profile_desc)
        
    files_paths = sys.argv[1]
    files_paths = files_paths.lstrip(FILE_SEPARATOR)
    
    files = files_paths.split(FILE_SEPARATOR)

    for f in files:
       t = WaveformCreator(f, profile_desc)
       t.start()
       t.join()
예제 #9
0
def get_render_data_for_current_selections():
    render_data = ToolsRenderData()
    profile_desc = widgets.profile_panel.out_profile_combo.categories_combo.get_selected()
    render_data.profile_index = mltprofiles.get_profile_index_for_profile(mltprofiles.get_profile(profile_desc))
    render_data.use_default_profile = widgets.profile_panel.use_project_profile_check.get_active()
    render_data.encoding_option_index = widgets.encoding_panel.encoding_selector.get_selected_encoding_index()
    render_data.quality_option_index = widgets.encoding_panel.quality_selector.widget.get_active()
    render_data.presets_index = 0 # presents rendering not available
    render_data.use_preset_encodings = False # presents rendering not available
    render_data.render_dir = "/" + widgets.file_panel.out_folder.get_uri().lstrip("file:/")
    render_data.file_name = widgets.file_panel.movie_name.get_text()
    render_data.file_extension = widgets.file_panel.extension_label.get_text()
    
    if widgets.video_clip_panel != None:
        render_data.do_video_render = (widgets.video_clip_panel.video_clip_combo.get_active() == 0)
        render_data.save_internally = (widgets.file_panel.render_location_combo.get_active() == 0)
        render_data.frame_name = widgets.file_panel.frame_name.get_text()

    return render_data
예제 #10
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()
        """
예제 #11
0
def _render_reverse_clip_dialog_callback(dialog, response_id, fb_widgets,
                                         media_file):
    if response_id == Gtk.ResponseType.ACCEPT:
        print("_render_reverse_clip_dialog_callback")

        # speed, filename folder
        speed = float(int(fb_widgets.hslider.get_value())) / 100.0
        file_name = fb_widgets.file_name.get_text()
        filenames = fb_widgets.out_folder.get_filenames()
        folder = filenames[0]
        write_file = folder + "/" + file_name + fb_widgets.extension_label.get_text(
        )

        if os.path.exists(write_file):
            primary_txt = _("A File with given path exists!")
            secondary_txt = _(
                "It is not allowed to render Motion Files with same paths as existing files.\nSelect another name for file."
            )
            dialogutils.warning_message(primary_txt, secondary_txt, dialog)
            return

        # Profile
        profile_desc = fb_widgets.categories_combo.get_selected()
        profile = mltprofiles.get_profile(profile_desc)
        profile_desc = profile_desc.replace(" ", "_")

        # Render consumer properties
        encoding_option_index = fb_widgets.encodings_cb.get_active()
        quality_option_index = fb_widgets.quality_cb.get_active()

        # Range
        range_selection = fb_widgets.render_range.get_active()

        dialog.destroy()

        # Create motion producer
        source_path = media_file.path
        if media_file.is_proxy_file == True:
            source_path = media_file.second_file_path

        motion_producer = mlt.Producer(
            profile, None,
            str("timewarp:" + str(speed) + ":" + str(source_path)))

        # start and end frames
        start_frame = 0
        end_frame = motion_producer.get_length() - 1
        render_full_range = True
        if range_selection == 1:
            start_frame = int(
                float(media_file.length - media_file.mark_out - 1) *
                (1.0 / -speed))
            end_frame = int(
                float(media_file.length - media_file.mark_out +
                      (media_file.mark_out - media_file.mark_in) + 1) *
                (1.0 / -speed)) + int(1.0 / -speed)

            if end_frame > motion_producer.get_length() - 1:
                end_frame = motion_producer.get_length() - 1
            if start_frame < 0:
                start_frame = 0

            render_full_range = False  # consumer wont stop automatically and needs to stopped explicitly

        session_id = hashlib.md5(str(
            os.urandom(32)).encode('utf-8')).hexdigest()

        args = ("session_id:" + str(session_id), "speed:" + str(speed),
                "write_file:" + str(write_file),
                "profile_desc:" + str(profile_desc),
                "encoding_option_index:" + str(encoding_option_index),
                "quality_option_index:" + str(quality_option_index),
                "source_path:" + str(source_path), "render_full_range:" +
                str(render_full_range), "start_frame:" + str(start_frame),
                "end_frame:" + str(end_frame))

        job_queue_object = jobs.MotionRenderJobQueueObject(
            session_id, write_file, args)
        job_queue_object.add_to_queue()
    else:
        dialog.destroy()
예제 #12
0
def save_project(project, file_path, changed_profile_desc=None):
    """
    Creates pickleable project object
    """
    print "Save project " + os.path.basename(file_path)

    # Get shallow copy
    s_proj = copy.copy(project)

    # Implements "change profile" functionality
    global _fps_conv_mult
    _fps_conv_mult = 1.0
    if changed_profile_desc != None:
        print mltprofiles.get_profile(
            changed_profile_desc), mltprofiles.get_profile(
                s_proj.profile_desc), s_proj.profile_desc
        _fps_conv_mult = mltprofiles.get_profile(changed_profile_desc).fps(
        ) / mltprofiles.get_profile(s_proj.profile_desc).fps()
        s_proj.profile_desc = changed_profile_desc
        print "Saving changed profile project: ", changed_profile_desc
        print "FPS conversion multiplier:", _fps_conv_mult

    # Set current sequence index
    s_proj.c_seq_index = project.sequences.index(project.c_seq)

    # Set project SAVEFILE_VERSION to current in case this is a resave of older file type.
    # Older file type has been converted to newer file type on load.
    s_proj.SAVEFILE_VERSION = appconsts.SAVEFILE_VERSION

    # Init proxy convert data
    global project_proxy_mode, proxy_path_dict
    project_proxy_mode = s_proj.proxy_data.proxy_mode
    proxy_path_dict = {}

    # Replace media file objects with pickleable copys
    media_files = {}
    for k, v in s_proj.media_files.iteritems():
        s_media_file = copy.copy(v)
        remove_attrs(s_media_file, MEDIA_FILE_REMOVE)

        # Convert media files between original and proxy files
        if project_proxy_mode == appconsts.CONVERTING_TO_USE_PROXY_MEDIA:
            if s_media_file.has_proxy_file:
                proxy_path_dict[
                    s_media_file.path] = s_media_file.second_file_path
                s_media_file.set_as_proxy_media_file()
        elif project_proxy_mode == appconsts.CONVERTING_TO_USE_ORIGINAL_MEDIA:
            if s_media_file.is_proxy_file:
                proxy_path_dict[
                    s_media_file.path] = s_media_file.second_file_path
                s_media_file.set_as_original_media_file()

        # Change paths when doing snapshot save. Image sequences are not
        # md5 hashed and are saved in folders and need to be looked up by relative search
        # when loading.
        if snapshot_paths != None:
            if s_media_file.type != appconsts.PATTERN_PRODUCER and s_media_file.type != appconsts.IMAGE_SEQUENCE:
                s_media_file.path = snapshot_paths[s_media_file.path]

        media_files[s_media_file.id] = s_media_file

    s_proj.media_files = media_files

    # Replace sequences with pickleable objects
    sequences = []
    for i in range(0, len(project.sequences)):
        add_seq = project.sequences[i]
        sequences.append(get_p_sequence(add_seq))
    s_proj.sequences = sequences

    # Remove unpickleable attributes
    remove_attrs(s_proj, PROJECT_REMOVE)

    # Write out file.
    write_file = file(file_path, "wb")
    pickle.dump(s_proj, write_file)
예제 #13
0
def get_current_profile():
    profile_desc = widgets.profile_panel.out_profile_combo.categories_combo.get_selected(
    )
    profile = mltprofiles.get_profile(profile_desc)
    return profile
예제 #14
0
def _out_profile_changed(categories_combo):
    # FIXME: 'out_profile_combo' is actually the panel containing the combobox
    profile_desc = widgets.profile_panel.out_profile_combo.categories_combo.get_selected(
    )
    profile = mltprofiles.get_profile(profile_desc)
    _fill_info_box(profile)
예제 #15
0
def main(root_path, force_launch=False):

    gtk_version = "%s.%s.%s" % (Gtk.get_major_version(), Gtk.get_minor_version(), Gtk.get_micro_version())
    editorstate.gtk_version = gtk_version
    try:
        editorstate.mlt_version = mlt.LIBMLT_VERSION
    except:
        editorstate.mlt_version = "0.0.99" # magic string for "not found"

    global _session_id
    _session_id = md5.new(os.urandom(16)).hexdigest()

    # Set paths.
    respaths.set_paths(root_path)

    # Init session folders
    if os.path.exists(get_session_folder()):
        shutil.rmtree(get_session_folder())
        
    os.mkdir(get_session_folder())

    # Load editor prefs and list of recent projects
    editorpersistance.load()


    # Init translations module with translations data
    translations.init_languages()
    translations.load_filters_translations()
    mlttransitions.init_module()

    # Load aniamtions data
    natronanimations.load_animations_projects_xml()

    # Init gtk threads
    Gdk.threads_init()
    Gdk.threads_enter()

    # Set monitor sizes
    """
    scr_w = Gdk.Screen.width()
    scr_h = Gdk.Screen.height()
    editorstate.SCREEN_WIDTH = scr_w
    editorstate.SCREEN_HEIGHT = scr_h
    if editorstate.screen_size_large_height() == True and editorstate.screen_size_small_width() == False:
        global MONITOR_WIDTH, MONITOR_HEIGHT
        MONITOR_WIDTH = 650
        MONITOR_HEIGHT = 400 # initial value, this gets changed when material is loaded
    """
    
    # Request dark theme if so desired
    if editorpersistance.prefs.theme != appconsts.LIGHT_THEME:
        Gtk.Settings.get_default().set_property("gtk-application-prefer-dark-theme", True)
        if editorpersistance.prefs.theme == appconsts.FLOWBLADE_THEME:
            gui.apply_gtk_css()

    # We need mlt fpr profiles handling
    repo = mlt.Factory().init()

    # Set numeric locale to use "." as radix, MLT initilizes this to OS locale and this causes bugs 
    locale.setlocale(locale.LC_NUMERIC, 'C')

    # Check for codecs and formats on the system
    mltenv.check_available_features(repo)
    renderconsumer.load_render_profiles()

    # Load filter and compositor descriptions from xml files.
    mltfilters.load_filters_xml(mltenv.services)
    mlttransitions.load_compositors_xml(mltenv.transitions)

    # Create list of available mlt profiles
    mltprofiles.load_profile_list()

    gui.load_current_colors()
    
    # Set launch profile
    profile_name = sys.argv[1].replace("_", " ") # we had underscores put in to pass as single arg
    print profile_name
    global _profile
    _profile = mltprofiles.get_profile(profile_name)
    
    global _animation_instance
    _animation_instance = natronanimations.get_default_animation_instance(_profile)
        
    global _window
    _window = NatronAnimatationsToolWindow()
    _window.pos_bar.set_dark_bg_color()

    Gtk.main()
    Gdk.threads_leave()
예제 #16
0
def load_project(file_path, icons_and_thumnails=True):
    _show_msg("Unpickling")

    # Load project object
    f = open(file_path)
    project = pickle.load(f)

    global _load_file_path
    _load_file_path = file_path

    # editorstate.project needs to be available for sequence building
    editorstate.project = project

    if (not hasattr(project, "SAVEFILE_VERSION")):
        project.SAVEFILE_VERSION = 1  # first save files did not have this
    print "Loading " + project.name + ", SAVEFILE_VERSION:", project.SAVEFILE_VERSION

    # Set MLT profile. NEEDS INFO USER ON MISSING PROFILE!!!!!
    project.profile = mltprofiles.get_profile(project.profile_desc)

    FIX_MISSING_PROJECT_ATTRS(project)

    # Some profiles may not be available in system
    # inform user on fix
    if project.profile == None:
        raise ProjectProfileNotFoundError(project.profile_desc)

    # Add MLT objects to sequences.
    global all_clips, sync_clips
    for seq in project.sequences:
        FIX_N_TO_3_SEQUENCE_COMPATIBILITY(seq)
        _show_msg(_("Building sequence ") + seq.name)
        all_clips = {}
        sync_clips = []

        seq.profile = project.profile
        fill_sequence_mlt(seq, project.SAVEFILE_VERSION)

        handle_seq_watermark(seq)

        if not hasattr(seq, "seq_len"):
            seq.update_edit_tracks_length()

    all_clips = {}
    sync_clips = []

    for k, media_file in project.media_files.iteritems():
        if project.SAVEFILE_VERSION < 4:
            FIX_N_TO_4_MEDIA_FILE_COMPATIBILITY(media_file)
        media_file.current_frame = 0  # this is always reset on load, value is not considered persistent
        if media_file.type != appconsts.PATTERN_PRODUCER:
            media_file.path = get_media_asset_path(media_file.path,
                                                   _load_file_path)

    # Add icons to media files
    if icons_and_thumnails == True:
        _show_msg(_("Loading icons"))
        for k, media_file in project.media_files.iteritems():
            media_file.create_icon()

    project.c_seq = project.sequences[project.c_seq_index]
    if icons_and_thumnails == True:
        project.init_thumbnailer()

    return project
예제 #17
0
def set_current_profile_for_profile_name(profile_name):
    global _current_profile
    _current_profile = mltprofiles.get_profile(profile_name)
예제 #18
0
def save_project(project, file_path, changed_profile_desc=None):
    """
    Creates pickleable project object
    """
    print "Save project " + os.path.basename(file_path)

    # Get shallow copy
    s_proj = copy.copy(project)

    # Implements "change profile" functionality
    global _fps_conv_mult, _xml_new_paths_for_profile_change
    _fps_conv_mult = 1.0
    if changed_profile_desc != None:
        _fps_conv_mult = mltprofiles.get_profile(changed_profile_desc).fps(
        ) / mltprofiles.get_profile(s_proj.profile_desc).fps()
        s_proj.profile_desc = changed_profile_desc
        _xml_new_paths_for_profile_change = {
        }  # dict acts also as a flag to show that profile change save is happening
        new_profile = mltprofiles.get_profile(changed_profile_desc)
        print "Saving changed profile project: ", changed_profile_desc
        print "FPS conversion multiplier:", _fps_conv_mult
    else:
        _xml_new_paths_for_profile_change = None  # None value acts also as a flag to show that profile change save is _not_ happening

    # Set current sequence index
    s_proj.c_seq_index = project.sequences.index(project.c_seq)

    # Set project SAVEFILE_VERSION to current in case this is a resave of older file type.
    # Older file type has been converted to newer file type on load.
    s_proj.SAVEFILE_VERSION = appconsts.SAVEFILE_VERSION

    # Init proxy convert data
    global project_proxy_mode, proxy_path_dict
    project_proxy_mode = s_proj.proxy_data.proxy_mode
    proxy_path_dict = {}

    # Replace media file objects with pickleable copys
    media_files = {}
    for k, v in s_proj.media_files.iteritems():
        s_media_file = copy.copy(v)

        # Because of MLT misfeature of changing project profile when loading MLT XML files we need to create new modified XML files when
        # saving to change profile.
        # Underlying reason: https://github.com/mltframework/mlt/issues/212
        if changed_profile_desc != None and s_media_file.path != None and utils.is_mlt_xml_file(
                s_media_file.path) == True:
            new_xml_file_path = _save_changed_xml_file(s_media_file,
                                                       new_profile)
            _xml_new_paths_for_profile_change[
                s_media_file.path] = new_xml_file_path
            s_media_file.path = new_xml_file_path
            print "XML path replace for media:", s_media_file.path, new_xml_file_path

        # Remove unpicleable attrs
        remove_attrs(s_media_file, MEDIA_FILE_REMOVE)

        # Convert media files between original and proxy files
        if project_proxy_mode == appconsts.CONVERTING_TO_USE_PROXY_MEDIA:
            if s_media_file.has_proxy_file:
                proxy_path_dict[
                    s_media_file.path] = s_media_file.second_file_path
                s_media_file.set_as_proxy_media_file()
        elif project_proxy_mode == appconsts.CONVERTING_TO_USE_ORIGINAL_MEDIA:
            if s_media_file.is_proxy_file:
                proxy_path_dict[
                    s_media_file.path] = s_media_file.second_file_path
                s_media_file.set_as_original_media_file()

        # Change paths when doing snapshot save. Image sequences are not
        # md5 hashed and are saved in folders and need to be looked up by relative search
        # when loading.
        if snapshot_paths != None:
            if s_media_file.type != appconsts.PATTERN_PRODUCER and s_media_file.type != appconsts.IMAGE_SEQUENCE:
                s_media_file.path = snapshot_paths[s_media_file.path]

        media_files[s_media_file.id] = s_media_file

    s_proj.media_files = media_files

    # Replace sequences with pickleable objects
    sequences = []
    for i in range(0, len(project.sequences)):
        add_seq = project.sequences[i]
        sequences.append(get_p_sequence(add_seq))
    s_proj.sequences = sequences

    # Remove unpickleable attributes
    remove_attrs(s_proj, PROJECT_REMOVE)

    # Write out file.
    write_file = file(file_path, "wb")
    pickle.dump(s_proj, write_file)
예제 #19
0
def _out_profile_changed(categorized_combo):
    profile = mltprofiles.get_profile(categorized_combo.get_selected())
    _fill_info_box(profile)
예제 #20
0
    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()
예제 #21
0
def load_project(file_path, icons_and_thumnails=True, relinker_load=False):
    _show_msg("Unpickling")

    project = utils.unpickle(file_path)

    # Relinker only operates on pickleable python data 
    if relinker_load:
        persistancecompat.FIX_MISSING_PROJECT_ATTRS(project)
        return project

    global _load_file_path
    _load_file_path = file_path

    # We need to collect some proxy data to try to fix projects with missing proxy files.
    global project_proxy_mode, proxy_path_dict
    project_proxy_mode = project.proxy_data.proxy_mode
    proxy_path_dict = {}
    
    # editorstate.project needs to be available for sequence building
    editorstate.project = project

    # Set MLT profile. NEEDS INFO USER ON MISSING PROFILE!!!!!
    project.profile = mltprofiles.get_profile(project.profile_desc)

    persistancecompat.FIX_MISSING_PROJECT_ATTRS(project)

    # Some profiles may not be available in system
    # inform user on fix
    if project.profile == None:
        raise ProjectProfileNotFoundError(project.profile_desc)

    for k, media_file in project.media_files.items():
        media_file.current_frame = 0 # this is always reset on load, value is not considered persistent

        # Avoid crash in case path attribute is missing (color clips).
        # All code in loop below handles issues not related to color clips.
        if not hasattr(media_file, "path"):
            continue
            
        # Try to find relative path files if needed for non-proxy media files
        orig_path = media_file.path # looking for missing path changes it and we need save this info for user info dialog on missing asset
        if media_file.is_proxy_file == False:
            if media_file.type != appconsts.PATTERN_PRODUCER and media_file.type != appconsts.IMAGE_SEQUENCE:
                media_file.path = get_media_asset_path(media_file.path, _load_file_path)
            elif media_file.type == appconsts.IMAGE_SEQUENCE:
                media_file.path = get_img_seq_media_path(media_file.path, _load_file_path)
        else:
            # Try to fix missing proxy project media files.
            # This is all just best effort, proxy files should never be deleted during editing
            # and proxy projects should not be moved.
            if media_file.type != appconsts.PATTERN_PRODUCER and media_file.type != appconsts.IMAGE_SEQUENCE:
                media_file.path = get_media_asset_path(media_file.path, _load_file_path)
                if media_file.path == NOT_FOUND:
                    fixed_second_path = get_media_asset_path(media_file.second_file_path, _load_file_path)
                    if fixed_second_path != NOT_FOUND:
                        media_file.path = fixed_second_path
                        media_file.second_file_path = fixed_second_path

        if media_file.path == NOT_FOUND:
            raise FileProducerNotFoundError(orig_path)

        persistancecompat.FIX_MISSING_MEDIA_FILE_ATTRS(media_file)
            
        # Use this to try to fix clips with missing proxy files.
        proxy_path_dict[media_file.path] = media_file.second_file_path
        
        # Try to fix possible missing proxy files for media assets if we are in proxy mode.
        if not os.path.isfile(media_file.path) and media_file.is_proxy_file and project_proxy_mode == appconsts.USE_PROXY_MEDIA:
            if os.path.isfile(media_file.second_file_path): # Original media file exists, use it
                media_file.set_as_original_media_file()

        _show_msg("Loading Media Item: " + media_file.name)

    # Add MLT objects to sequences.
    global all_clips, sync_clips
    seq_count = 1
    for seq in project.sequences:
            
        persistancecompat.FIX_MISSING_SEQUENCE_ATTRS(seq)

        _show_msg(_("Building sequence ") + str(seq_count))
        all_clips = {}
        sync_clips = []
                
        seq.profile = project.profile
        fill_sequence_mlt(seq, project.SAVEFILE_VERSION)

        handle_seq_watermark(seq)

        if not hasattr(seq, "seq_len"):
            seq.update_edit_tracks_length()

        seq_count = seq_count + 1

    all_clips = {}
    sync_clips = []

    if icons_and_thumnails == True:
        _show_msg(_("Loading icons"))
        for k, media_file in project.media_files.items():
            media_file.create_icon()
    
    project.c_seq = project.sequences[project.c_seq_index]
    if icons_and_thumnails == True:
        project.init_thumbnailer()

    return project
예제 #22
0
    def run(self):        
        self.running = True
        items = 0
        global render_queue, batch_window
        for render_item in render_queue.queue:
            if self.running == False:
                break
            if render_item.render_this_item == False:
                continue
            
            current_render_time = 0

            # Create render objects
            identifier = render_item.generate_identifier()
            project_file_path = get_projects_dir() + identifier + ".flb"
            persistance.show_messages = False

            project = persistance.load_project(project_file_path, False)

            producer = project.c_seq.tractor
            profile = mltprofiles.get_profile(render_item.render_data.profile_name)
            consumer = renderconsumer.get_mlt_render_consumer(render_item.render_path, 
                                                              profile,
                                                              render_item.args_vals_list)

            # Get render range
            start_frame, end_frame, wait_for_stop_render = get_render_range(render_item)
            
            # Create and launch render thread
            global render_thread 
            render_thread = renderconsumer.FileRenderPlayer(None, producer, consumer, start_frame, end_frame) # None == file name not needed this time when using FileRenderPlayer because callsite keeps track of things
            render_thread.wait_for_producer_end_stop = wait_for_stop_render
            render_thread.start()

            # Set render start time and item state
            render_item.render_started()

            Gdk.threads_enter()
            batch_window.update_queue_view()
            batch_window.current_render.set_text("  " + render_item.get_display_name())
            Gdk.threads_leave()

            # Make sure that render thread is actually running before
            # testing render_thread.running value later
            while render_thread.has_started_running == False:
                time.sleep(0.05)

            # View update loop
            self.thread_running = True
            self.aborted = False
            while self.thread_running:
                if self.aborted == True:
                    break        
                render_fraction = render_thread.get_render_fraction()
                now = time.time()
                current_render_time = now - render_item.start_time
                
                Gdk.threads_enter()
                batch_window.update_render_progress(render_fraction, items, render_item.get_display_name(), current_render_time)
                Gdk.threads_leave()
                
                if render_thread.running == False: # Rendering has reached end
                    self.thread_running = False
                    
                    Gdk.threads_enter()
                    batch_window.render_progress_bar.set_fraction(1.0)
                    Gdk.threads_leave()
                                    
                    render_item.render_completed()
                else:
                    time.sleep(0.33)
                    
            if not self.aborted:
                items = items + 1
                Gdk.threads_enter()
                batch_window.update_render_progress(0, items, render_item.get_display_name(), 0)
                Gdk.threads_leave()
            else:
                if render_item != None:
                    render_item.render_aborted()
                    break
            render_thread.shutdown()
        
        # Update view for render end
        Gdk.threads_enter()
        batch_window.reload_queue() # item may havee added to queue while rendering
        batch_window.render_queue_stopped()
        Gdk.threads_leave()
예제 #23
0
    def run(self):      
        hidden_dir = utils.get_hidden_user_dir_path()

        try:
            data_file_path = hidden_dir + CURRENT_RENDER_RENDER_ITEM
            data_file = open(data_file_path)
            render_item = pickle.load(data_file)
            self.error_status = None
        except Exception as e:
            if self.error_status == None:
                self.error_status = []
            self.error_status = ("Current render datafile load failed with ") + str(e)
            # something 
            return 

        current_render_time = 0

        # Create render objects
        project_file_path = hidden_dir + CURRENT_RENDER_PROJECT_FILE
        persistance.show_messages = False

        project = persistance.load_project(project_file_path, False)

        producer = project.c_seq.tractor
        profile = mltprofiles.get_profile(render_item.render_data.profile_name)
        consumer = renderconsumer.get_mlt_render_consumer(render_item.render_path, 
                                                          profile,
                                                          render_item.args_vals_list)

        # Get render range
        start_frame, end_frame, wait_for_stop_render = get_render_range(render_item)
        
        # Create and launch render thread
        render_thread = renderconsumer.FileRenderPlayer(None, producer, consumer, start_frame, end_frame) # None == file name not needed this time when using FileRenderPlayer because callsite keeps track of things
        render_thread.wait_for_producer_end_stop = wait_for_stop_render
        render_thread.start()

        # Set render start time and item state
        render_item.render_started()

        Gdk.threads_enter()
        #single_render_window.update_queue_view()
        single_render_window.current_render.set_text("  " + os.path.basename(render_item.render_path))
        Gdk.threads_leave()

        # Make sure that render thread is actually running before
        # testing render_thread.running value later
        while render_thread.has_started_running == False:
            time.sleep(0.05)

        # View update loop
        self.running = True

        while self.running:
            render_fraction = render_thread.get_render_fraction()
            now = time.time()
            current_render_time = now - render_item.start_time
            
            Gdk.threads_enter()
            single_render_window.update_render_progress(render_fraction, render_item.get_display_name(), current_render_time)
            Gdk.threads_leave()
            
            if render_thread.running == False: # Rendering has reached end
                self.running = False
                
                Gdk.threads_enter()
                single_render_window.render_progress_bar.set_fraction(1.0)
                Gdk.threads_leave()

            time.sleep(0.33)
                
        render_thread.shutdown()
        global single_render_thread
        single_render_thread = None
        # Update view for render end
        GLib.idle_add(_single_render_shutdown)
예제 #24
0
def save_project(project, file_path, changed_profile_desc=None):
    """
    Creates pickleable project object
    """
    print "Saving project..."  # + os.path.basename(file_path)
    
    # Get shallow copy
    s_proj = copy.copy(project)
    
    # Implements "change profile" functionality
    global _fps_conv_mult, _xml_new_paths_for_profile_change
    _fps_conv_mult = 1.0
    if changed_profile_desc != None:
        _fps_conv_mult = mltprofiles.get_profile(changed_profile_desc).fps() / mltprofiles.get_profile(s_proj.profile_desc).fps()
        s_proj.profile_desc = changed_profile_desc
        _xml_new_paths_for_profile_change = {} # dict acts also as a flag to show that profile change save is happening
        new_profile = mltprofiles.get_profile(changed_profile_desc)
        #print "Saving changed profile project: ", changed_profile_desc
        #print "FPS conversion multiplier:", _fps_conv_mult
    else:
        _xml_new_paths_for_profile_change = None # None value acts also as a flag to show that profile change save is _not_ happening

    # Set current sequence index
    s_proj.c_seq_index = project.sequences.index(project.c_seq)
    
    # Set project SAVEFILE_VERSION to current in case this is a resave of older file type.
    # Older file type has been converted to newer file type on load.
    s_proj.SAVEFILE_VERSION = appconsts.SAVEFILE_VERSION

    # Init proxy convert data
    global project_proxy_mode, proxy_path_dict
    project_proxy_mode = s_proj.proxy_data.proxy_mode
    proxy_path_dict = {}

    # Replace media file objects with pickleable copys
    media_files = {}
    for k, v in s_proj.media_files.iteritems():
        s_media_file = copy.copy(v)
        
        # Because of MLT misfeature of changing project profile when loading MLT XML files we need to create new modified XML files when
        # saving to change profile.
        # Underlying reason: https://github.com/mltframework/mlt/issues/212
        if changed_profile_desc != None and s_media_file.path != None and utils.is_mlt_xml_file(s_media_file.path) == True:
            new_xml_file_path = _save_changed_xml_file(s_media_file, new_profile)
            _xml_new_paths_for_profile_change[s_media_file.path] = new_xml_file_path
            s_media_file.path = new_xml_file_path
            #print "XML path replace for media:", s_media_file.path,  new_xml_file_path

        # Remove unpicleable attrs
        remove_attrs(s_media_file, MEDIA_FILE_REMOVE)

        # Convert media files between original and proxy files
        if project_proxy_mode == appconsts.CONVERTING_TO_USE_PROXY_MEDIA:
            if s_media_file.has_proxy_file:
                proxy_path_dict[s_media_file.path] = s_media_file.second_file_path
                s_media_file.set_as_proxy_media_file()
        elif project_proxy_mode == appconsts.CONVERTING_TO_USE_ORIGINAL_MEDIA:
            if s_media_file.is_proxy_file:
                proxy_path_dict[s_media_file.path] = s_media_file.second_file_path
                s_media_file.set_as_original_media_file()

        # Change paths when doing snapshot save. Image sequences are not 
        # md5 hashed and are saved in folders and need to be looked up by relative search
        # when loading.
        if snapshot_paths != None:
            if s_media_file.type != appconsts.PATTERN_PRODUCER and  s_media_file.type != appconsts.IMAGE_SEQUENCE:
                s_media_file.path = snapshot_paths[s_media_file.path] 

        media_files[s_media_file.id] = s_media_file

    s_proj.media_files = media_files

    # Replace sequences with pickleable objects
    sequences = []
    for i in range(0, len(project.sequences)):
        add_seq = project.sequences[i]
        sequences.append(get_p_sequence(add_seq))
    s_proj.sequences = sequences

    # Remove unpickleable attributes
    remove_attrs(s_proj, PROJECT_REMOVE)

    # Write out file.
    with atomicfile.AtomicFileWriter(file_path, "wb") as afw:
        write_file = afw.get_file()
        pickle.dump(s_proj, write_file)
예제 #25
0
    def run(self):
        self.start_time = time.monotonic()

        if self.lookup_path == "None":
            # Video clips

            proxy_profile = mltprofiles.get_profile(self.proxy_profile_desc)

            # App wrote the temp profile when launching proxy render.
            # NOTE: this needs to be created here for future
            proxy_profile_path = userfolders.get_cache_dir(
            ) + "temp_proxy_profile"
            proxy_profile = mlt.Profile(proxy_profile_path)

            renderconsumer.performance_settings_enabled = False  # uuh...we're obivously disabling something momentarily.
            consumer = renderconsumer.get_render_consumer_for_encoding(
                self.proxy_file_path, proxy_profile,
                renderconsumer.proxy_encodings[self.enc_index])
            renderconsumer.performance_settings_enabled = True

            consumer.set("vb", str(int(self.proxy_rate)) + "k")
            consumer.set("rescale", "nearest")

            file_producer = mlt.Producer(proxy_profile,
                                         str(self.media_file_path))

            start_frame = 0
            end_frame = file_producer.get_length() - 1

            self.render_player = renderconsumer.FileRenderPlayer(
                None, file_producer, consumer, 0, end_frame)
            self.render_player.wait_for_producer_end_stop = False
            self.render_player.start()

            while self.render_player.stopped == False:

                self.check_abort_requested()

                if self.abort == True:
                    self.render_player.shutdown()
                    return

                fraction = self.render_player.get_render_fraction()
                self.render_update(fraction)

                time.sleep(0.3)

        else:
            # Image Sequences

            copyfolder, copyfilename = os.path.split(self.proxy_file_path)
            if not os.path.isdir(copyfolder):
                os.makedirs(copyfolder)

            listing = glob.glob(self.lookup_path)
            size = self.proxy_w, self.proxy_h
            done = 0
            for orig_path in listing:
                orig_folder, orig_file_name = os.path.split(orig_path)

                try:
                    im = Image.open(orig_path)
                    im.thumbnail(size, Image.ANTIALIAS)
                    im.save(copyfolder + "/" + orig_file_name, "PNG")
                except IOError:
                    print("proxy img seq frame failed for '%s'" % orig_path)

                done = done + 1

                if done % 5 == 0:
                    fraction = float(done) / float(len(listing))
                    self.render_update(fraction)

        # Write out completed flag file.
        ccrutils.write_completed_message()
예제 #26
0
def load_project(file_path, icons_and_thumnails=True, relinker_load=False):
    _show_msg("Unpickling")

    # Load project object
    f = open(file_path)
    project = pickle.load(f)

    # Relinker only operates on pickleable python data 
    if relinker_load:
        FIX_MISSING_PROJECT_ATTRS(project)
        return project

    global _load_file_path
    _load_file_path = file_path
    
    # editorstate.project needs to be available for sequence building
    editorstate.project = project

    if(not hasattr(project, "SAVEFILE_VERSION")):
        project.SAVEFILE_VERSION = 1 # first save files did not have this
    # SvdB - Feb-2017 - Removed project.name from print. It causes problems with non-latin characters, in some cases. Not sure why, yet.
    print "Loading Project, SAVEFILE_VERSION:", project.SAVEFILE_VERSION

    # Set MLT profile. NEEDS INFO USER ON MISSING PROFILE!!!!!
    project.profile = mltprofiles.get_profile(project.profile_desc)

    FIX_MISSING_PROJECT_ATTRS(project)

    # Some profiles may not be available in system
    # inform user on fix
    if project.profile == None:
        raise ProjectProfileNotFoundError(project.profile_desc)

    # Add MLT objects to sequences.
    global all_clips, sync_clips
    seq_count = 1
    for seq in project.sequences:
        FIX_N_TO_3_SEQUENCE_COMPATIBILITY(seq)
        _show_msg(_("Building sequence ") + str(seq_count))
        all_clips = {}
        sync_clips = []
                
        seq.profile = project.profile
        fill_sequence_mlt(seq, project.SAVEFILE_VERSION)

        handle_seq_watermark(seq)

        if not hasattr(seq, "seq_len"):
            seq.update_edit_tracks_length()

        seq_count = seq_count + 1

    all_clips = {}
    sync_clips = []

    for k, media_file in project.media_files.iteritems():
        if project.SAVEFILE_VERSION < 4:
            FIX_N_TO_4_MEDIA_FILE_COMPATIBILITY(media_file)
        media_file.current_frame = 0 # this is always reset on load, value is not considered persistent
        if media_file.type != appconsts.PATTERN_PRODUCER and media_file.type != appconsts.IMAGE_SEQUENCE:
            media_file.path = get_media_asset_path(media_file.path, _load_file_path)
        elif media_file.type == appconsts.IMAGE_SEQUENCE:
            media_file.path = get_img_seq_media_path(media_file.path, _load_file_path)
            
        # This fixes Media Relinked projects with SAVEFILE_VERSION < 4:
        # Remove 2018
        if (not(hasattr(media_file,  "is_proxy_file"))):
            FIX_N_TO_4_MEDIA_FILE_COMPATIBILITY(media_file)
        # This attr was added for 1.8. It is not computed for older projects.
        if (not hasattr(media_file, "info")):
            media_file.info = None
        # We need this in all media files, used only by img seq media
        if not hasattr(media_file, "ttl"):
            media_file.ttl = None
                
    if(not hasattr(project, "update_media_lengths_on_load")):
        project.update_media_lengths_on_load = True # old projects < 1.10 had wrong media length data which just was never used.
                                                    # 1.10 needed that data for the first time and required recreating it correctly for older projects
    
    if icons_and_thumnails == True:
        _show_msg(_("Loading icons"))
        for k, media_file in project.media_files.iteritems():
            media_file.create_icon()
    
    project.c_seq = project.sequences[project.c_seq_index]
    if icons_and_thumnails == True:
        project.init_thumbnailer()

    return project
예제 #27
0
def load_project(file_path, icons_and_thumnails=True, relinker_load=False):
    _show_msg("Unpickling")

    # Load project object
    f = open(file_path)
    project = pickle.load(f)

    # Relinker only operates on pickleable python data 
    if relinker_load:
        FIX_MISSING_PROJECT_ATTRS(project)
        return project

    global _load_file_path
    _load_file_path = file_path
    
    # editorstate.project needs to be available for sequence building
    editorstate.project = project

    if(not hasattr(project, "SAVEFILE_VERSION")):
        project.SAVEFILE_VERSION = 1 # first save files did not have this
    print "Loading " + project.name + ", SAVEFILE_VERSION:", project.SAVEFILE_VERSION

    # Set MLT profile. NEEDS INFO USER ON MISSING PROFILE!!!!!
    project.profile = mltprofiles.get_profile(project.profile_desc)

    FIX_MISSING_PROJECT_ATTRS(project)

    # Some profiles may not be available in system
    # inform user on fix
    if project.profile == None:
        raise ProjectProfileNotFoundError(project.profile_desc)

    # Add MLT objects to sequences.
    global all_clips, sync_clips
    for seq in project.sequences:
        FIX_N_TO_3_SEQUENCE_COMPATIBILITY(seq)
        _show_msg(_("Building sequence ") + seq.name)
        all_clips = {}
        sync_clips = []
                
        seq.profile = project.profile
        fill_sequence_mlt(seq, project.SAVEFILE_VERSION)

        handle_seq_watermark(seq)

        if not hasattr(seq, "seq_len"):
            seq.update_edit_tracks_length()

    all_clips = {}
    sync_clips = []

    for k, media_file in project.media_files.iteritems():
        if project.SAVEFILE_VERSION < 4:
            FIX_N_TO_4_MEDIA_FILE_COMPATIBILITY(media_file)
        media_file.current_frame = 0 # this is always reset on load, value is not considered persistent
        if media_file.type != appconsts.PATTERN_PRODUCER and media_file.type != appconsts.IMAGE_SEQUENCE:
            media_file.path = get_media_asset_path(media_file.path, _load_file_path)
        elif media_file.type == appconsts.IMAGE_SEQUENCE:
            media_file.path = get_img_seq_media_path(media_file.path, _load_file_path)
            
        # This fixes Media Relinked projects with SAVEFILE_VERSION < 4:
        # Remove 2018
        if (not(hasattr(media_file,  "is_proxy_file"))):
            FIX_N_TO_4_MEDIA_FILE_COMPATIBILITY(media_file)
        # This attr was added for 1.8. It is not computed for older projects.
        if (not hasattr(media_file, "info")):
            media_file.info = None
       
    if icons_and_thumnails == True:
        _show_msg(_("Loading icons"))
        for k, media_file in project.media_files.iteritems():
            media_file.create_icon()
    
    project.c_seq = project.sequences[project.c_seq_index]
    if icons_and_thumnails == True:
        project.init_thumbnailer()

    return project
예제 #28
0
def load_project(file_path, icons_and_thumnails=True, relinker_load=False):
    _show_msg("Unpickling")

    # Load project object
    f = open(file_path)
    project = pickle.load(f)

    # Relinker only operates on pickleable python data
    if relinker_load:
        FIX_MISSING_PROJECT_ATTRS(project)
        return project

    global _load_file_path
    _load_file_path = file_path

    # editorstate.project needs to be available for sequence building
    editorstate.project = project

    if (not hasattr(project, "SAVEFILE_VERSION")):
        project.SAVEFILE_VERSION = 1  # first save files did not have this
    # SvdB - Feb-2017 - Removed project.name from print. It causes problems with non-latin characters, in some cases. Not sure why, yet.
    print "Loading Project, SAVEFILE_VERSION:", project.SAVEFILE_VERSION

    # Set MLT profile. NEEDS INFO USER ON MISSING PROFILE!!!!!
    project.profile = mltprofiles.get_profile(project.profile_desc)

    FIX_MISSING_PROJECT_ATTRS(project)

    # Some profiles may not be available in system
    # inform user on fix
    if project.profile == None:
        raise ProjectProfileNotFoundError(project.profile_desc)

    # Add MLT objects to sequences.
    global all_clips, sync_clips
    for seq in project.sequences:
        FIX_N_TO_3_SEQUENCE_COMPATIBILITY(seq)
        _show_msg(_("Building sequence ") + seq.name)
        all_clips = {}
        sync_clips = []

        seq.profile = project.profile
        fill_sequence_mlt(seq, project.SAVEFILE_VERSION)

        handle_seq_watermark(seq)

        if not hasattr(seq, "seq_len"):
            seq.update_edit_tracks_length()

    all_clips = {}
    sync_clips = []

    for k, media_file in project.media_files.iteritems():
        if project.SAVEFILE_VERSION < 4:
            FIX_N_TO_4_MEDIA_FILE_COMPATIBILITY(media_file)
        media_file.current_frame = 0  # this is always reset on load, value is not considered persistent
        if media_file.type != appconsts.PATTERN_PRODUCER and media_file.type != appconsts.IMAGE_SEQUENCE:
            media_file.path = get_media_asset_path(media_file.path,
                                                   _load_file_path)
        elif media_file.type == appconsts.IMAGE_SEQUENCE:
            media_file.path = get_img_seq_media_path(media_file.path,
                                                     _load_file_path)

        # This fixes Media Relinked projects with SAVEFILE_VERSION < 4:
        # Remove 2018
        if (not (hasattr(media_file, "is_proxy_file"))):
            FIX_N_TO_4_MEDIA_FILE_COMPATIBILITY(media_file)
        # This attr was added for 1.8. It is not computed for older projects.
        if (not hasattr(media_file, "info")):
            media_file.info = None

    if (not hasattr(project, "update_media_lengths_on_load")):
        project.update_media_lengths_on_load = True  # old projects < 1.10 had wrong media length data which just was never used.
        # 1.10 needed that data for the first time and required recreating it correctly for older projects

    if icons_and_thumnails == True:
        _show_msg(_("Loading icons"))
        for k, media_file in project.media_files.iteritems():
            media_file.create_icon()

    project.c_seq = project.sequences[project.c_seq_index]
    if icons_and_thumnails == True:
        project.init_thumbnailer()

    return project
예제 #29
0
def load_project(file_path, icons_and_thumnails=True, relinker_load=False):
    _show_msg("Unpickling")

    project = utils.unpickle(file_path)

    # Relinker only operates on pickleable python data
    if relinker_load:
        FIX_MISSING_PROJECT_ATTRS(project)
        return project

    global _load_file_path
    _load_file_path = file_path

    # We need to collect some proxy data to try to fix projects with missing proxy files.
    global project_proxy_mode, proxy_path_dict
    project_proxy_mode = project.proxy_data.proxy_mode
    proxy_path_dict = {}

    # editorstate.project needs to be available for sequence building
    editorstate.project = project

    if (not hasattr(project, "SAVEFILE_VERSION")):
        project.SAVEFILE_VERSION = 1  # first save files did not have this
    # SvdB - Feb-2017 - Removed project.name from print. It causes problems with non-latin characters, in some cases. Not sure why, yet.
    print("Loading Project, SAVEFILE_VERSION:", project.SAVEFILE_VERSION)

    # Set MLT profile. NEEDS INFO USER ON MISSING PROFILE!!!!!
    project.profile = mltprofiles.get_profile(project.profile_desc)

    FIX_MISSING_PROJECT_ATTRS(project)

    # Some profiles may not be available in system
    # inform user on fix
    if project.profile == None:
        raise ProjectProfileNotFoundError(project.profile_desc)

    for k, media_file in project.media_files.items():
        if project.SAVEFILE_VERSION < 4:
            FIX_N_TO_4_MEDIA_FILE_COMPATIBILITY(media_file)
        media_file.current_frame = 0  # this is always reset on load, value is not considered persistent

        # This fixes Media Relinked projects with SAVEFILE_VERSION < 4:
        if (not (hasattr(media_file, "is_proxy_file"))):
            FIX_N_TO_4_MEDIA_FILE_COMPATIBILITY(media_file)

        # Try to find relative path files if needed for non-proxy media files
        if media_file.is_proxy_file == False:
            if media_file.type != appconsts.PATTERN_PRODUCER and media_file.type != appconsts.IMAGE_SEQUENCE:
                media_file.path = get_media_asset_path(media_file.path,
                                                       _load_file_path)
            elif media_file.type == appconsts.IMAGE_SEQUENCE:
                media_file.path = get_img_seq_media_path(
                    media_file.path, _load_file_path)

        # This attr was added for 1.8. It is not computed for older projects.
        if (not hasattr(media_file, "info")):
            media_file.info = None
        # We need this in all media files, used only by img seq media
        if not hasattr(media_file, "ttl"):
            media_file.ttl = None

        # Use this to try to fix clips with missing proxy files.
        proxy_path_dict[media_file.path] = media_file.second_file_path

        # Try to fix possible missing proxy files for media assets if we are in proxy mode.
        if not os.path.isfile(
                media_file.path
        ) and media_file.is_proxy_file and project_proxy_mode == appconsts.USE_PROXY_MEDIA:
            if os.path.isfile(media_file.second_file_path
                              ):  # Original media file exists, use it
                media_file.set_as_original_media_file()

    # Add MLT objects to sequences.
    global all_clips, sync_clips
    seq_count = 1
    for seq in project.sequences:
        FIX_N_TO_3_SEQUENCE_COMPATIBILITY(seq)

        if not hasattr(seq, "compositing_mode"):
            seq.compositing_mode = appconsts.COMPOSITING_MODE_TOP_DOWN_FREE_MOVE

        _show_msg(_("Building sequence ") + str(seq_count))
        all_clips = {}
        sync_clips = []

        seq.profile = project.profile
        fill_sequence_mlt(seq, project.SAVEFILE_VERSION)

        handle_seq_watermark(seq)

        if not hasattr(seq, "seq_len"):
            seq.update_edit_tracks_length()

        seq_count = seq_count + 1

    all_clips = {}
    sync_clips = []

    if (not hasattr(project, "update_media_lengths_on_load")):
        project.update_media_lengths_on_load = True  # old projects < 1.10 had wrong media length data which just was never used.
        # 1.10 needed that data for the first time and required recreating it correctly for older projects

    if icons_and_thumnails == True:
        _show_msg(_("Loading icons"))
        for k, media_file in project.media_files.items():
            media_file.create_icon()

    project.c_seq = project.sequences[project.c_seq_index]
    if icons_and_thumnails == True:
        project.init_thumbnailer()

    return project
예제 #30
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()
예제 #31
0
def main(root_path, force_launch=False):

    gtk_version = "%s.%s.%s" % (Gtk.get_major_version(), Gtk.get_minor_version(), Gtk.get_micro_version())
    editorstate.gtk_version = gtk_version
    try:
        editorstate.mlt_version = mlt.LIBMLT_VERSION
    except:
        editorstate.mlt_version = "0.0.99" # magic string for "not found"

    global _session_id
    _session_id = md5.new(os.urandom(16)).hexdigest()

    # Set paths.
    respaths.set_paths(root_path)

    # Init session folders
    if os.path.exists(get_session_folder()):
        shutil.rmtree(get_session_folder())
        
    os.mkdir(get_session_folder())

    # Load editor prefs and list of recent projects
    editorpersistance.load()


    # Init translations module with translations data
    translations.init_languages()
    translations.load_filters_translations()
    mlttransitions.init_module()

    # Load aniamtions data
    natronanimations.load_animations_projects_xml()

    # Init gtk threads
    Gdk.threads_init()
    Gdk.threads_enter()

    # Set monitor sizes
    """
    scr_w = Gdk.Screen.width()
    scr_h = Gdk.Screen.height()
    editorstate.SCREEN_WIDTH = scr_w
    editorstate.SCREEN_HEIGHT = scr_h
    if editorstate.screen_size_large_height() == True and editorstate.screen_size_small_width() == False:
        global MONITOR_WIDTH, MONITOR_HEIGHT
        MONITOR_WIDTH = 650
        MONITOR_HEIGHT = 400 # initial value, this gets changed when material is loaded
    """
    
    # Request dark theme if so desired
    if editorpersistance.prefs.theme != appconsts.LIGHT_THEME:
        Gtk.Settings.get_default().set_property("gtk-application-prefer-dark-theme", True)
        if editorpersistance.prefs.theme == appconsts.FLOWBLADE_THEME:
            gui.apply_gtk_css()

    # We need mlt fpr profiles handling
    repo = mlt.Factory().init()
    processutils.prepare_mlt_repo(repo)
    
    # Set numeric locale to use "." as radix, MLT initilizes this to OS locale and this causes bugs 
    locale.setlocale(locale.LC_NUMERIC, 'C')

    # Check for codecs and formats on the system
    mltenv.check_available_features(repo)
    renderconsumer.load_render_profiles()

    # Load filter and compositor descriptions from xml files.
    mltfilters.load_filters_xml(mltenv.services)
    mlttransitions.load_compositors_xml(mltenv.transitions)

    # Create list of available mlt profiles
    mltprofiles.load_profile_list()

    gui.load_current_colors()
    
    # Set launch profile
    profile_name = sys.argv[1].replace("_", " ") # we had underscores put in to pass as single arg
    print profile_name
    global _profile
    _profile = mltprofiles.get_profile(profile_name)
    
    global _animation_instance
    _animation_instance = natronanimations.get_default_animation_instance(_profile)
        
    global _window
    _window = NatronAnimatationsToolWindow()
    _window.pos_bar.set_dark_bg_color()

    Gtk.main()
    Gdk.threads_leave()