Пример #1
0
def get_queue(queue_file: Path) -> List[Video]:
    if not queue_file.exists():
        return []

    try:
        loaded = Box.from_yaml(filename=queue_file)
    except (BoxError, YAMLError):
        logger.exception("Could not open queue")
        return []

    queue = []
    for video in loaded["queue"]:
        video["source"] = Path(video["source"])
        video["work_path"] = Path(video["work_path"])
        video["video_settings"]["output_path"] = Path(
            video["video_settings"]["output_path"])
        encoder_settings = video["video_settings"]["video_encoder_settings"]
        ves = [
            x(**encoder_settings) for x in setting_types.values()
            if x().name == encoder_settings["name"]
        ][0]
        audio = [
            AudioTrack(**x) for x in video["video_settings"]["audio_tracks"]
        ]
        subtitles = [
            SubtitleTrack(**x)
            for x in video["video_settings"]["subtitle_tracks"]
        ]
        attachments = []
        for x in video["video_settings"]["attachment_tracks"]:
            try:
                attachment_path = x.pop("file_path")
            except KeyError:
                attachment_path = None
            attachment = AttachmentTrack(**x)
            attachment.file_path = Path(attachment_path)
            attachments.append(attachment)
        status = Status(**video["status"])
        crop = None
        if video["video_settings"]["crop"]:
            crop = Crop(**video["video_settings"]["crop"])
        del video["video_settings"]["audio_tracks"]
        del video["video_settings"]["subtitle_tracks"]
        del video["video_settings"]["attachment_tracks"]
        del video["video_settings"]["video_encoder_settings"]
        del video["status"]
        del video["video_settings"]["crop"]
        vs = VideoSettings(
            **video["video_settings"],
            audio_tracks=audio,
            subtitle_tracks=subtitles,
            attachment_tracks=attachments,
            crop=crop,
        )
        vs.video_encoder_settings = ves  # No idea why this has to be called after, otherwise reset to x265
        del video["video_settings"]
        queue.append(Video(**video, video_settings=vs, status=status))
    return queue
Пример #2
0
 def update_audio_settings(self):
     tracks = []
     for track in self.tracks:
         if track.enabled:
             tracks.append(
                 AudioTrack(
                     index=track.index,
                     outdex=track.outdex,
                     conversion_bitrate=track.conversion["bitrate"],
                     conversion_codec=track.conversion["codec"],
                     codec=track.codec,
                     downmix=track.downmix,
                     title=track.title,
                     language=track.language,
                 ))
     self.app.fastflix.current_video.video_settings.audio_tracks = tracks
Пример #3
0
 def update_audio_settings(self):
     tracks = []
     for track in self.tracks:
         if track.enabled:
             tracks.append(
                 AudioTrack(
                     index=track.index,
                     outdex=track.outdex,
                     conversion_bitrate=track.conversion["bitrate"],
                     conversion_codec=track.conversion["codec"],
                     codec=track.codec,
                     downmix=track.downmix,
                     title=track.title,
                     language=track.language,
                     profile=track.profile,
                     channels=track.channels,
                     enabled=track.enabled,
                     original=track.original,
                     raw_info=track.all_info,
                     friendly_info=track.audio,
                 ))
     self.app.fastflix.current_video.video_settings.audio_tracks = tracks