Exemple #1
0
    def write_image(self, file_path):
        """
        Writes thumbnail image from file producer
        """
        # Get data
        md_str = md5.new(file_path).hexdigest()
        thumbnail_path = editorpersistance.prefs.thumbnail_folder + "/" + md_str + ".png"

        # Create consumer
        consumer = mlt.Consumer(self.profile, "avformat", thumbnail_path)
        consumer.set("real_time", 0)
        consumer.set("vcodec", "png")

        # Create one frame producer
        producer = mlt.Producer(self.profile, str(file_path))
        if producer.is_valid() == False:
            raise ProducerNotValidError(file_path)

        info = utils.get_file_producer_info(producer)

        length = producer.get_length()
        frame = length / 2
        producer = producer.cut(frame, frame)

        # Connect and write image
        consumer.connect(producer)
        consumer.run()

        return (thumbnail_path, length, info)
Exemple #2
0
def _display_file_info(media_file):
    # get info
    clip = current_sequence().create_file_producer_clip(media_file.path)
    info = utils.get_file_producer_info(clip)

    width = info["width"]
    height = info["height"]
    size = str(width) + " x " + str(height)
    length = utils.get_tc_string(info["length"])

    try:
        img = guiutils.get_gtk_image_from_file(media_file.icon_path, 300)
    except:
        print "_display_file_info() failed to get thumbnail"
    
    vcodec = info["vcodec"]
    acodec = info["acodec"]
    
    channels = str(info["channels"]) 
    frequency =  str(info["frequency"]) + "Hz"
        
    try:
        num = info["fps_num"]
        den = info["fps_den"]
        fps = float(num/den) 
    except:
        fps ="N/A"
    
    dialogs.file_properties_dialog((media_file, img, size, length, vcodec, acodec, channels, frequency, fps))
Exemple #3
0
    def write_image(self, file_path):
        """
        Writes thumbnail image from file producer
        """
        # Get data
        md_str = md5.new(file_path).hexdigest()
        thumbnail_path = editorpersistance.prefs.thumbnail_folder + "/" + md_str +  ".png"

        # Create consumer
        consumer = mlt.Consumer(self.profile, "avformat", 
                                     thumbnail_path)
        consumer.set("real_time", 0)
        consumer.set("vcodec", "png")

        # Create one frame producer
        producer = mlt.Producer(self.profile, str(file_path))
        if producer.is_valid() == False:
            raise ProducerNotValidError(file_path)

        info = utils.get_file_producer_info(producer)

        length = producer.get_length()
        frame = length / 2
        producer = producer.cut(frame, frame)

        # Connect and write image
        consumer.connect(producer)
        consumer.run()
        
        return (thumbnail_path, length, info)
Exemple #4
0
def _write_thumbnail_image(profile, file_path, action_object):
    """
    Writes thumbnail image from file producer
    """
    # Get data
    thumbnail_path = action_object.get_container_thumbnail_path()

    # Create consumer
    consumer = mlt.Consumer(profile, "avformat", thumbnail_path)
    consumer.set("real_time", 0)
    consumer.set("vcodec", "png")

    # Create one frame producer
    producer = mlt.Producer(profile, str(file_path))
    if producer.is_valid() == False:
        raise ProducerNotValidError(file_path)

    info = utils.get_file_producer_info(producer)

    length = producer.get_length()
    frame = length // 2
    producer = producer.cut(frame, frame)

    # Connect and write image
    consumer.connect(producer)
    consumer.run()

    return (thumbnail_path, length, info)
Exemple #5
0
    def write_image(self, file_path):
        """
        Writes thumbnail image from file producer
        """
        # Get data
        md_str = hashlib.md5(file_path.encode('utf-8')).hexdigest()
        thumbnail_path = userfolders.get_cache_dir(
        ) + appconsts.THUMBNAILS_DIR + "/" + md_str + ".png"

        # Create consumer
        consumer = mlt.Consumer(self.profile, "avformat", thumbnail_path)
        consumer.set("real_time", 0)
        consumer.set("vcodec", "png")

        # Create one frame producer
        producer = mlt.Producer(self.profile, str(file_path))
        if producer.is_valid() == False:
            raise ProducerNotValidError(file_path)

        info = utils.get_file_producer_info(producer)

        length = producer.get_length()
        frame = length // 2
        producer = producer.cut(frame, frame)

        # Connect and write image
        consumer.connect(producer)
        consumer.run()

        return (thumbnail_path, length, info)
Exemple #6
0
def set_current_profile(clip_path):
    profile = mltprofiles.get_default_profile()
    producer = mlt.Producer(profile, str(clip_path))
    global _current_profile
    profile_index = mltprofiles.get_closest_matching_profile_index(utils.get_file_producer_info(producer))
    _current_profile = mltprofiles.get_profile_for_index(profile_index)
    return profile_index
Exemple #7
0
def set_current_profile(clip_path):
    profile = mltprofiles.get_default_profile()
    producer = mlt.Producer(profile, str(clip_path))
    global _current_profile
    profile_index = mltprofiles.get_closest_matching_profile_index(utils.get_file_producer_info(producer))
    _current_profile = mltprofiles.get_profile_for_index(profile_index)
    return profile_index
Exemple #8
0
def _display_file_info(media_file):
    # get info
    clip = current_sequence().create_file_producer_clip(media_file.path)
    info = utils.get_file_producer_info(clip)

    width = info["width"]
    height = info["height"]
    size = str(width) + " x " + str(height)
    length = utils.get_tc_string(info["length"])

    try:
        img = guiutils.get_gtk_image_from_file(media_file.icon_path, 300)
    except:
        print "_display_file_info() failed to get thumbnail"

    vcodec = info["vcodec"]
    acodec = info["acodec"]

    channels = str(info["channels"])
    frequency = str(info["frequency"]) + "Hz"

    try:
        num = info["fps_num"]
        den = info["fps_den"]
        fps = float(num / den)
    except:
        fps = "N/A"

    dialogs.file_properties_dialog((media_file, img, size, length, vcodec,
                                    acodec, channels, frequency, fps))
Exemple #9
0
def _display_file_info(media_file):
    # get info
    clip = current_sequence().create_file_producer_clip(media_file.path)
    info = utils.get_file_producer_info(clip)

    width = info["width"]
    height = info["height"]
    if media_file.type == appconsts.IMAGE:
        graphic_img = Image.open(media_file.path)
        width, height = graphic_img.size

    size = str(width) + " x " + str(height)
    length = utils.get_tc_string(info["length"])

    try:
        img = guiutils.get_gtk_image_from_file(media_file.icon_path, 300)
    except:
        print "_display_file_info() failed to get thumbnail"

    vcodec = info["vcodec"]
    acodec = info["acodec"]

    if vcodec == None:
        vcodec = _("N/A")
    if acodec == None:
        acodec = _("N/A")

    channels = str(info["channels"])
    frequency = str(info["frequency"]) + "Hz"

    if media_file.type == appconsts.VIDEO:
        match_profile_index = mltprofiles.get_closest_matching_profile_index(
            info)
        match_profile_name = mltprofiles.get_profile_name_for_index(
            match_profile_index)
    else:
        match_profile_name = _("N/A")

    if media_file.type == appconsts.VIDEO:
        if media_file.matches_project_profile():
            matches_project_profile = _("Yes")
        else:
            matches_project_profile = _("No")
    else:
        matches_project_profile = _("N/A")

    try:
        num = info["fps_num"]
        den = info["fps_den"]
        fps = float(num / den)
    except:
        fps = _("N/A")

    dialogs.file_properties_dialog(
        (media_file, img, size, length, vcodec, acodec, channels, frequency,
         fps, match_profile_name, matches_project_profile))
Exemple #10
0
def _display_file_info(media_file):
    # get info
    clip = current_sequence().create_file_producer_clip(media_file.path)
    info = utils.get_file_producer_info(clip)

    width = info["width"]
    height = info["height"]
    if media_file.type == appconsts.IMAGE:
        graphic_img = Image.open(media_file.path)
        width, height = graphic_img.size 

    size = str(width) + " x " + str(height)
    length = utils.get_tc_string(info["length"])

    try:
        img = guiutils.get_gtk_image_from_file(media_file.icon_path, 300)
    except:
        print "_display_file_info() failed to get thumbnail"
    
    vcodec = info["vcodec"]
    acodec = info["acodec"]
    
    if vcodec == None:
        vcodec = _("N/A")
    if acodec == None:
        acodec = _("N/A")

    channels = str(info["channels"]) 
    frequency =  str(info["frequency"]) + "Hz"

    if media_file.type == appconsts.VIDEO:
        match_profile_index = mltprofiles.get_closest_matching_profile_index(info)
        match_profile_name =  mltprofiles.get_profile_name_for_index(match_profile_index)
    else:
        match_profile_name = _("N/A")
    
    if media_file.type == appconsts.VIDEO:
        if media_file.matches_project_profile():
            matches_project_profile = _("Yes")
        else:
            matches_project_profile = _("No")
    else:
        matches_project_profile = _("N/A")
        
    try:
        num = info["fps_num"]
        den = info["fps_den"]
        fps = float(num/den) 
    except:
        fps = _("N/A")
    
    dialogs.file_properties_dialog((media_file, img, size, length, vcodec, acodec, channels, frequency, fps, match_profile_name, matches_project_profile))
Exemple #11
0
def get_clip_profile_index(clip_path):
    profile = mltprofiles.get_default_profile()
    producer = mlt.Producer(profile, str(clip_path))
    profile_index = mltprofiles.get_closest_matching_profile_index(utils.get_file_producer_info(producer))
    return profile_index
Exemple #12
0
def get_clip_profile_index(clip_path):
    profile = mltprofiles.get_default_profile()
    producer = mlt.Producer(profile, str(clip_path))
    profile_index = mltprofiles.get_closest_matching_profile_index(utils.get_file_producer_info(producer))
    return profile_index