Exemplo n.º 1
0
def do_wizardry() -> None:
    """It's magic"""

    filtered = filtering()
    if isinstance(filtered, vs.VideoNode):
        filtered = cast(vs.VideoNode, filtered)
    else:
        raise ValueError

    if not Path(WEB_AOD.name_clip_output).exists():
        X265Encoder(
            'x265',
            Path('settings/x265_settings'),
            filtered,
            WEB_AOD,
            progress_update=lambda v, e: print(
                f"\rVapourSynth: {v}/{e} ~ {100 * v // e}% || Encoder: ",
                end=""))

    if not Path(WEB_AOD.a_src.format(1)).exists():
        BasicTool('mkvextract',
                  [WEB_AOD.src, 'tracks', f'1:{WEB_AOD.a_src.format(1)}'])

    assert WEB_AOD.a_src is not None
    BasicTool('mkvmerge', [
        '-o', WEB_AOD.name_file_final, '--track-name',
        '0:HEVC WEBRip by Vardë@Raws-Maji', '--language', '0:jpn',
        WEB_AOD.name_clip_output, '--track-name', '0:AAC 2.0', '--language',
        '0:jpn',
        WEB_AOD.a_src.format(1)
    ])
Exemplo n.º 2
0
    def run(self) -> None:
        assert self.file.a_src
        assert self.file.a_enc_cut

        v_encoder = X265Encoder('x265', 'settings/x265_settings_BD_NCOP1v09')

        a_extracters = [
            BasicTool(
                'eac3to',
                [JPBD_NCOP2.path.to_str(),
                 '2:', self.file.a_src.format(2).to_str()]
            )
        ]

        a_cutters = [AudioCutter(self.file, track=2)]
        a_encoders = [FlacEncoder(self.file, track=2)]

        muxer = Mux(
            self.file,
            streams=(
                VideoStream(self.file.name_clip_output, 'HEVC BDRip by LightArrowsEXE@Kaleido', JAPANESE),
                AudioStream(self.file.a_enc_cut.format(1), 'FLAC 2.0', JAPANESE),
                None
            )
        )

        config = RunnerConfig(v_encoder, None, a_extracters, a_cutters, a_encoders, muxer)

        runner = SelfRunner(self.clip, self.file, config)
        runner.run()
        runner.do_cleanup()
Exemplo n.º 3
0
    def run(self) -> None:
        assert self.file.a_src
        assert self.file.a_src_cut

        v_encoder = X265Encoder('settings/x265_settings_BD')

        ap_video_source(
            self.file.path_without_ext.to_str() +
            ".mkv",  # mkv because >chapters first and begna's code breaks
            [self.file.frame_start, self.file.frame_end],
            framerate=self.clip.fps,
            noflac=True,
            noaac=False,
            nocleanup=False,
            silent=False)
        os.rename(self.file.path_without_ext.to_str() + "_2_cut.aac",
                  self.file.a_src_cut.to_str())

        muxer = Mux(self.file,
                    streams=(VideoStream(
                        self.file.name_clip_output,
                        'HEVC BDrip by LightArrowsEXE@Kaleido', JAPANESE),
                             AudioStream(self.file.a_src_cut.format(1),
                                         'AAC 2.0', JAPANESE, XML_TAG), None))

        config = RunnerConfig(v_encoder, None, None, None, None, muxer)

        runner = SelfRunner(self.clip, self.file, config)
        runner.run()
        runner.do_cleanup()
Exemplo n.º 4
0
    def run(self) -> None:
        assert self.file.a_src
        assert self.file.a_enc_cut

        self.preqpfileflt()

        v_encoder = X265Encoder('x265', 'settings/x265_settings_BD')

        p = Patch(file_to_fix=f'premux/{JPBD_NCOP.name[:-2]}01 (Premux).mkv',
                  filtered_clip=filtered,
                  frame_start=281,
                  frame_end=527,
                  encoder=X265Encoder('x265', 'settings/x265_settings_BD'),
                  file=JPBD_NCOP,
                  output_filename=VPath(fr"{JPBD_NCOP.name} (Premux).mkv"))
        p.run()
        p.do_cleanup()
Exemplo n.º 5
0
    def _encode(self: EncodeGoBrrr):
        if self.file.do_lossless:
            NvencEncoder('C:/NVEncC_5.30_x64/NVEncC64.exe', Path('love_live_common/nvenc_settings'),
                         self.clip, self.file, progress_update=None)
            self.clip = core.lsmas.LWLibavSource(self.file.name_clip_output_lossless)

        X265Encoder('x265', Path('love_live_common/x265_settings'), self.clip, self.file,
                    progress_update=lambda v, e:
                        print(f"\rVapourSynth: {v}/{e} ~ {100 * v // e}% || Encoder: ", end=""))
Exemplo n.º 6
0
    def run(self, clean_up: bool = True, make_comp: bool = True) -> None:
        """
        :param clean_up:    Perform clean-up procedure after encoding
        :param make_comp:   Create a slowpics-compatible comparison between src, flt, and enc
        """
        v_encoder = X265Encoder('settings/x265_settings_BD')
        v_lossless_encoder = FFV1Encoder()
        self.clip = dither_down(self.clip)

        video_track = VideoStream(self.file.name_clip_output,
                                  'HEVC BDRip by LightArrowsEXE@Kaleido',
                                  JAPANESE)

        audio_files = video_source(self.file.path.to_str(),
                                   out_file=self.file.a_src_cut,
                                   trim_list=resolve_trims(
                                       self.file.trims_or_dfs),
                                   trims_framerate=self.file.clip.fps,
                                   frames_total=self.file.clip.num_frames,
                                   flac=False,
                                   aac=True,
                                   silent=False)

        audio_tracks: List[AudioStream] = []
        for track in audio_files:
            audio_tracks += [
                AudioStream(VPath(track), 'AAC 2.0', JAPANESE, XML_TAG)
            ]

        muxer = Mux(self.file, streams=(video_track, audio_tracks, None))

        config = RunnerConfig(v_encoder=v_encoder,
                              v_lossless_encoder=v_lossless_encoder,
                              a_extracters=None,
                              a_cutters=None,
                              a_encoders=None,
                              muxer=muxer)

        runner = SelfRunner(self.clip, self.file, config)
        runner.run()

        if clean_up:
            runner.do_cleanup()
            for at in audio_files:
                try:
                    os.remove(at)
                except FileNotFoundError:
                    Status.warn(f"File {at} not found! Skipping...")

        if make_comp:
            try:
                generate_comparison(self.file,
                                    self.file.name_file_final.to_str(),
                                    self.clip)
            except ValueError as e:
                print(e)
Exemplo n.º 7
0
 def _encode(self: EncodeGoBrrr) -> None:
     if not Path(self.file.name_clip_output):
         X265Encoder(
             'x265',
             Path('churutto_common/x265_settings'),
             self.clip,
             self.file,
             progress_update=lambda v, e: print(
                 f"\rVapourSynth: {v}/{e} ~ {100 * v // e}% || Encoder: ",
                 end=""))
Exemplo n.º 8
0
    def run(self,
            clean_up: bool = True,
            make_comp: bool = False,
            settings: str = 'x265_settings_BD') -> None:
        """
        :param clean_up:    Perform clean-up procedure after encoding
        :param make_comp:   Create a slowpics-compatible comparison between src, flt, and enc
        """
        v_encoder = X265Encoder(f'settings/{settings}')
        v_lossless_encoder = FFV1Encoder()
        self.clip = dither_down(self.clip)

        video_track = VideoStream(self.file.name_clip_output,
                                  'HEVC TVrip by LightArrowsEXE@Kaleido',
                                  JAPANESE)

        a_extracters = [
            BasicTool('eac3to', [
                self.file.path.to_str(), '2:',
                self.file.a_src.set_track(1).to_str()
            ])
        ]

        a_cutters = [EztrimCutter(self.file, track=1)]

        muxer = Mux(self.file,
                    streams=(video_track,
                             AudioStream(self.file.a_src_cut.set_track(1),
                                         'AAC 2.0', JAPANESE), None))

        config = RunnerConfig(v_encoder=v_encoder,
                              v_lossless_encoder=v_lossless_encoder,
                              a_extracters=a_extracters,
                              a_cutters=a_cutters,
                              a_encoders=None,
                              muxer=muxer)

        runner = SelfRunner(self.clip, self.file, config)
        runner.run()

        if clean_up:
            runner.do_cleanup()

        if make_comp:
            try:
                generate_comparison(self.file,
                                    self.file.name_file_final.to_str(),
                                    self.clip)
            except ValueError as e:
                print(e)
Exemplo n.º 9
0
    def run(self,
            clean_up: bool = True,
            zones: Optional[Dict[Tuple[int, int], Dict[str,
                                                       Any]]] = None) -> None:
        """
        :param clean_up:    Perform clean-up procedure after encoding
        :param zones:       Zones for x265
        """
        v_encoder = X265Encoder('settings/x265_settings', zones=zones)
        v_lossless_encoder = FFV1Encoder()
        self.clip = dither_down(self.clip)

        video_track = VideoStream(self.file.name_clip_output,
                                  'HEVC BDRip by LightArrowsEXE@Kaleido',
                                  JAPANESE)

        audio_files = video_source(self.file.path.to_str(),
                                   out_file=self.file.a_src_cut,
                                   trim_list=resolve_trims(
                                       self.file.trims_or_dfs),
                                   trims_framerate=self.file.clip.fps,
                                   frames_total=self.file.clip.num_frames,
                                   flac=True,
                                   aac=False,
                                   silent=False)

        audio_tracks: List[AudioStream] = []
        for track in audio_files:
            audio_tracks += [AudioStream(VPath(track), 'FLAC 2.0', JAPANESE)]

        muxer = Mux(self.file, streams=(video_track, audio_tracks, None))

        config = RunnerConfig(v_encoder=v_encoder,
                              v_lossless_encoder=v_lossless_encoder,
                              a_extracters=None,
                              a_cutters=None,
                              a_encoders=None,
                              muxer=muxer)

        runner = SelfRunner(self.clip, self.file, config)
        runner.run()

        if clean_up:
            runner.do_cleanup()
            for at in audio_files:
                try:
                    os.remove(at)
                except FileNotFoundError:
                    Status.warn(f"File {at} not found! Skipping...")
Exemplo n.º 10
0
    def run(self, clean_up: bool = True, make_comp: bool = True) -> None:
        """
        :param clean_up:    Perform clean-up procedure after encoding
        :param make_comp:   Create a slowpics-compatible comparison between src, flt, and enc
        """
        assert self.audio_file.a_src
        assert self.audio_file.a_enc_cut

        v_encoder = X265Encoder('settings/x265_settings')
        self.clip = dither_down(self.clip)

        audio_files = video_source(self.file.path.to_str(),
                                   trim_list=resolve_trims(
                                       self.file.trims_or_dfs),
                                   trims_framerate=self.file.clip.fps,
                                   flac=False,
                                   aac=True,
                                   silent=False)

        audio_tracks: List[AudioStream] = []
        for track in audio_files:
            audio_tracks += [
                AudioStream(VPath(track), 'AAC 2.0', JAPANESE, XML_TAG)
            ]

        muxer = Mux(self.file,
                    streams=(VideoStream(
                        self.file.name_clip_output,
                        'HEVC BDRip by LightArrowsEXE@Kaleido',
                        JAPANESE), audio_tracks, None))

        config = RunnerConfig(v_encoder, None, None, None, None, muxer)

        runner = SelfRunner(self.clip, self.file, config)
        runner.run()

        try:
            if make_comp:
                generate_comparison_NCOP1(self.file,
                                          self.file.name_file_final.to_str(),
                                          self.clip)
        except ValueError as e:
            Status.fail(str(e))

        if clean_up:
            runner.do_cleanup()
Exemplo n.º 11
0
    def __init__(self,
                 file: FileInfo,
                 clip: vs.VideoNode,
                 ED: int = None) -> None:
        self.file = file
        self.clip = clip
        assert self.file.a_src

        if ED:
            self.file.trims_or_dfs = [(self.file.trims_or_dfs[0], ED),
                                      (ED + 2152, ED + 2157), (ED, ED + 2152),
                                      (ED + 2157, self.file.trims_or_dfs[-1])]

        self.v_encoder = X265Encoder('../encode/settings')
        self.a_extracter = FFmpegAudioExtracter(self.file,
                                                track_in=1,
                                                track_out=1)
        self.a_cutters = EztrimCutter(self.file, track=1)
        self.a_encoders = QAACEncoder(self.file, track=1)
Exemplo n.º 12
0
    def patch(
            self,
            ranges: Union[Union[int, Tuple[int, int]],
                          List[Union[int, Tuple[int, int]]]],
            clean_up: bool = True,
            external_file: Optional[Union[os.PathLike[str],
                                          str]] = None) -> None:
        """
        :ranges:            Frame ranges that require patching. Expects as a list of tuples or integers (can be mixed).
                            Examples: [(0, 100), (400, 600)]; [50, (100, 200), 500]
        :param clean_up:    Perform clean-up procedure after patching
        :external_file:     File to patch into. This is intended for videos like NCs with only one or two changes
                            so you don't need to encode the entire thing multiple times.
                            It will copy the given file and rename it to ``FileInfo.name_file_final``.
                            If None, performs regular patching.
        """
        v_encoder = X265Encoder('settings/x265_settings')
        self.clip = dither_down(self.clip)

        if external_file:
            if os.path.exists(external_file):
                Status.info(
                    f"Copying {external_file} to {self.file.name_file_final}")
                shutil.copy(external_file, self.file.name_file_final)
            else:
                Status.warn(
                    f"{self.file.name_file_final} already exists; please ensure it's the correct file!"
                )

        runner = Patch(
            clip=self.clip,
            ranges=ranges,  # type:ignore[arg-type]
            encoder=v_encoder,
            file=self.file,
        )
        runner.run()

        new = f"{self.file.name_file_final.to_str()[:-4]}_new.mkv"
        Status.info(f"Replacing {self.file.name_file_final} -> {new}")
        os.replace(new, self.file.name_file_final)

        if clean_up:
            runner.do_cleanup()
Exemplo n.º 13
0
    def run(self,
            clean_up: bool = True,
            make_comp: bool = True,
            zones: Optional[Dict[Tuple[int, int], Dict[str,
                                                       Any]]] = None) -> None:
        """
        :param clean_up:    Perform clean-up procedure after encoding
        :param make_comp:   Create a slowpics-compatible comparison between src, flt, and enc
        """
        assert self.file.a_src

        v_encoder = X265Encoder(pick_settings(self.file), zones=zones)
        v_lossless_encoder = FFV1Encoder()
        self.clip = dither_down(self.clip)

        muxer = Mux(self.file,
                    streams=(VideoStream(
                        self.file.name_clip_output,
                        'HEVC Switch GameRip by LightArrowsEXE@Kaleido',
                        JAPANESE),
                             AudioStream(self.file.a_src_cut.format(0),
                                         'FLAC 2.0', JAPANESE), None))

        config = RunnerConfig(v_encoder=v_encoder,
                              v_lossless_encoder=v_lossless_encoder,
                              a_extracters=None,
                              a_cutters=None,
                              a_encoders=None,
                              muxer=muxer)

        runner = SelfRunner(self.clip, self.file, config)
        runner.run()

        if clean_up:
            runner.do_cleanup()

        if make_comp:
            try:
                generate_comparison(self.file,
                                    self.file.name_file_final.to_str(),
                                    self.clip)
            except ValueError as e:
                Status.fail(str(e))
Exemplo n.º 14
0
    def run(self,
            clean_up: bool = True,
            make_comp: bool = True,
            BDMV: bool = False,
            zones: Optional[Dict[Tuple[int, int], Dict[str,
                                                       Any]]] = None) -> None:
        """
        :param clean_up:    Perform clean-up procedure after encoding
        :param make_comp:   Create a slowpics-compatible comparison between src, flt, and enc
        """
        # assert self.file.a_src

        v_encoder = X265Encoder(pick_settings(self.file), zones=zones)
        v_lossless_encoder = FFV1Encoder()
        self.clip = dither_down(self.clip)

        if BDMV:  # For use with BDMVs, *not* Switch/PS4 rips
            audio_files = video_source(self.file.path.to_str(),
                                       out_file=self.file.a_src_cut,
                                       trim_list=resolve_trims(
                                           self.file.trims_or_dfs),
                                       trims_framerate=self.file.clip.fps,
                                       flac=True,
                                       aac=False,
                                       silent=False)

            audio_tracks: List[AudioStream] = []
            for track in audio_files:
                audio_tracks += [
                    AudioStream(VPath(track), 'FLAC 2.0', JAPANESE)
                ]
        else:
            a_extracters = FfmpegAudioExtracter(self.file,
                                                track_in=0,
                                                track_out=0)
            a_cutters = EztrimCutter(self.file, track=1)

        credit = 'HEVC GameRip by LightArrowsEXE@Kaleido' if not BDMV \
            else 'HEVC BDRip by LightArrowsEXE@Kaleido'
        muxer = Mux(
            self.file,
            streams=(VideoStream(
                self.file.name_clip_output, credit,
                JAPANESE), audio_tracks[0] if BDMV else AudioStream(
                    self.file.a_src_cut.set_track(1), 'AAC 2.0', JAPANESE),
                     None))

        config = RunnerConfig(v_encoder, v_lossless_encoder,
                              None if BDMV else a_extracters,
                              None if BDMV else a_cutters, None, muxer)

        runner = SelfRunner(self.clip, self.file, config)
        runner.run()

        if clean_up:
            runner.do_cleanup()
            for at in audio_files:
                try:
                    os.remove(at)
                except FileNotFoundError:
                    Status.warn(f"File {at} not found! Skipping")

        if make_comp:
            try:
                generate_comparison(self.file,
                                    self.file.name_file_final.to_str(),
                                    self.clip)
            except ValueError as e:
                Status.fail(str(e))
Exemplo n.º 15
0
    def run(self, clean_up: bool = True,
            make_comp: bool = True,
            wraw: bool = False,
            ep_num: Optional[int] = None) -> None:
        """
        :param clean_up:    Perform clean-up procedure after encoding
        :param make_comp:   Create a slowpics-compatible comparison between src, flt, and enc
        """
        assert self.file.a_src
        assert self.file.a_src_cut

        v_encoder = X265Encoder('settings/x265_settings') if not wraw \
            else X264Encoder('settings/x264_settings_wraw')
        self.clip = dither_down(self.clip)

        a_extracters = [
            BasicTool(
                'eac3to',
                [self.file.path.to_str(),
                 '2:', self.file.a_src.set_track(1).to_str()]
            )
        ]

        a_cutters = [EztrimCutter(self.file, track=1)]

        if self.chapter_list:
            assert self.file.chapter
            assert self.file.trims_or_dfs

            if not isinstance(self.chapter_offset, int):
                self.chapter_offset = self.file.trims_or_dfs[0] * -1  # type: ignore

            chapxml = MatroskaXMLChapters(self.file.chapter)
            chapxml.create(self.chapter_list, self.file.clip.fps)
            chapxml.shift_times(self.chapter_offset, self.file.clip.fps)  # type: ignore
            chapxml.set_names(self.chapter_names)
            chapters = ChapterStream(chapxml.chapter_file, JAPANESE)

        metadata_message = 'HEVC WEBrip by LightArrowsEXE@GoodJob!Media' if not wraw \
            else 'h264 Workraw by LightArrowsEXE@GoodJob!Media'

        muxer = Mux(
            self.file,
            streams=(
                VideoStream(self.file.name_clip_output, metadata_message, JAPANESE),
                AudioStream(self.file.a_src_cut.set_track(1), 'AAC 2.0', JAPANESE),
                chapters if self.chapter_list else None
            )
        )

        config = RunnerConfig(v_encoder, None, a_extracters, a_cutters, None, muxer)

        runner = SelfRunner(self.clip, self.file, config)
        runner.run()

        appendCRC(self.file.name_file_final)

        if make_comp:
            try:
                generate_comparison(self.file, self.file.name_file_final.to_str(), self.clip)
            except ValueError as e:
                Status.fail(f"{e}")

        if wraw:
            mini_file = self.file
            # One of our staff has limited internet, so we need to mini-fy one wraw.
            # Also this can 100% be written way nicer, but I am too lazy and This Works:tm:
            wraw2encoder = X264Encoder('settings/x264_settings_wraw_mini')
            mini_file.name_file_final = VPath(f"wraw/Jahy_{ep_num} (mini wraw).mkv")
            mini_file.name_clip_output = VPath(mini_file.name_clip_output.to_str()[:-4] + '_mini.265')

            wraw2muxer = Mux(
                mini_file,
                streams=(
                    VideoStream(mini_file.name_clip_output, metadata_message, JAPANESE),
                    AudioStream(self.file.a_src_cut.set_track(1), 'AAC 2.0', JAPANESE),
                    chapters if self.chapter_list else None
                )
            )

            wraw2config = RunnerConfig(wraw2encoder, None, a_extracters, a_cutters, None, wraw2muxer)

            wraw2runner = SelfRunner(self.clip, self.file, wraw2config)
            wraw2runner.run()

            appendCRC(mini_file.name_file_final)

            if make_comp:
                try:
                    generate_comparison(self.file, self.file.name_file_final.to_str(), self.clip)
                except ValueError as e:
                    Status.fail(f"{e}")

            if clean_up:
                wraw2runner.do_cleanup()

        if clean_up:
            try:
                runner.do_cleanup()
            except:
                pass
Exemplo n.º 16
0
WEB_AOD = FileInfo(
    fr'5-toubun no Hanayome S02 (The Quintessential Quintuplets S02) [AoD]\5-toubun no Hanayome S02E{NUM} [1080p+][AAC][JapDub][GerSub][Web-DL].mkv',
)
WEB_CRU = FileInfo(
    fr'5-toubun no Hanayome S02 (The Quintessential Quintuplets S02) [CR]\5-toubun no Hanayome S02E{NUM} [1080p][AAC][JapDub][GerEngSub][Web-DL].mkv'
)
SUB = fr'5-toubun_no_Hanayome_subs\ger\[FeelsBadSubs] 5-toubun no Hanayome ∬ - {NUM} [1080p].4.ger.ass'
FONTDIR = '5-toubun_no_Hanayome_subs/_fonts'

ENC_LOSS = LosslessEncoder('nvencc',
                           Path('gotoubun_common/nvenc_settings'),
                           progress_update=None)

ENCODER = X265Encoder(
    'x265',
    Path('gotoubun_common/x265_settings'),
    progress_update=lambda v, e: print(
        f"\rVapourSynth: {v}/{e} ~ {100 * v // e}% || Encoder: ", end=""))

A_EXTRACTER = BasicTool(
    'eac3to',
    [JPBD.src, '2:', JPBD.a_src.format(1), '-log=NUL'])
A_CUTTER = AudioCutter(JPBD, track=1)
A_ENCODER = AudioEncoder('qaac',
                         Path('gotoubun_common/qaac_settings'),
                         JPBD,
                         track=1)


class Filtering():
    def main(self) -> vs.VideoNode:
Exemplo n.º 17
0
    def run(self, clean_up: bool = True, make_comp: bool = True) -> None:
        """
        :param clean_up:    Perform clean-up procedure after encoding
        :param make_comp:   Create a slowpics-compatible comparison between src, flt, and enc
        """
        assert self.file.a_src

        v_encoder = X265Encoder('settings/x265_settings')
        self.clip = dither_down(self.clip)

        audio_files = video_source(self.file.path.to_str(),
                                   trimlist=verify_trim(
                                       self.file.trims_or_dfs),
                                   framerate=self.file.clip.fps,
                                   noflac=True,
                                   noaac=False,
                                   silent=False)

        audio_tracks: List[AudioStream] = []
        for track in audio_files:
            audio_tracks += [
                AudioStream(VPath(track), 'AAC 2.0', JAPANESE, XML_TAG)
            ]

        if self.chapter_list:
            assert self.file.chapter
            assert self.file.trims_or_dfs

            Path("/chapters").mkdir(parents=True, exist_ok=True)

            if not isinstance(self.chapter_offset, int):
                self.chapter_offset = self.file.trims_or_dfs[
                    0] * -1  # type: ignore

            chapxml = MatroskaXMLChapters(self.file.chapter)
            chapxml.create(self.chapter_list, self.file.clip.fps)
            chapxml.shift_times(self.chapter_offset,
                                self.file.clip.fps)  # type: ignore
            chapxml.set_names(self.chapter_names)
            chapters = ChapterStream(chapxml.chapter_file, JAPANESE)

        muxer = Mux(self.file,
                    streams=(VideoStream(
                        self.file.name_clip_output,
                        'HEVC BDRip by LightArrowsEXE@Kaleido',
                        JAPANESE), audio_tracks,
                             chapters if self.chapter_list else None))

        config = RunnerConfig(v_encoder, None, None, None, None, muxer)

        runner = SelfRunner(self.clip, self.file, config)
        runner.run()

        try:
            if make_comp:
                generate_comparison(self.file,
                                    self.file.name_file_final.to_str(),
                                    self.clip)
        except ValueError as e:
            Status.fail(str(e))

        if clean_up:
            runner.do_cleanup()
Exemplo n.º 18
0
    def run(self,
            clean_up: bool = True,
            make_comp: bool = True,
            zones: Optional[Dict[Tuple[int, int], Dict[str,
                                                       Any]]] = None) -> None:
        """
        :param clean_up:    Perform clean-up procedure after encoding
        :param make_comp:   Create a slowpics-compatible comparison between src, flt, and enc
        """
        assert self.file.a_src

        v_encoder = X265Encoder(pick_settings(self.file), zones=zones)
        v_lossless_encoder = FFV1Encoder()
        self.clip = dither_down(self.clip)

        a_extracters = FfmpegAudioExtracter(self.file, track_in=0, track_out=0)
        a_cutters = EztrimCutter(self.file, track=1)

        if self.chapter_list:
            assert self.file.chapter
            assert self.file.trims_or_dfs

            if not isinstance(self.chapter_offset, int):
                self.chapter_offset = self.file.trims_or_dfs[
                    0] * -1  # type: ignore

            chapxml = MatroskaXMLChapters(self.file.chapter)
            chapxml.create(self.chapter_list, self.file.clip.fps)
            chapxml.shift_times(self.chapter_offset,
                                self.file.clip.fps)  # type: ignore
            chapxml.set_names(self.chapter_names)
            chapters = ChapterStream(chapxml.chapter_file, JAPANESE)

        muxer = Mux(self.file,
                    streams=(VideoStream(
                        self.file.name_clip_output,
                        'HEVC TVrip by LightArrowsEXE@Kaleido', JAPANESE),
                             AudioStream(self.file.a_src_cut.set_track(1),
                                         'AAC 2.0', JAPANESE),
                             chapters if self.chapter_list else None))

        config = RunnerConfig(v_encoder=v_encoder,
                              v_lossless_encoder=v_lossless_encoder,
                              a_extracters=a_extracters,
                              a_cutters=a_cutters,
                              a_encoders=None,
                              muxer=muxer)

        runner = SelfRunner(self.clip, self.file, config)
        runner.run()

        if clean_up:
            runner.do_cleanup()

        if make_comp:
            try:
                generate_comparison(self.file,
                                    self.file.name_file_final.to_str(),
                                    self.clip)
            except ValueError as e:
                Status.fail(str(e))
Exemplo n.º 19
0
    def run(self,
            clean_up: bool = True,
            make_comp: bool = True,
            zones: Optional[Dict[Tuple[int, int], Dict[str,
                                                       Any]]] = None) -> None:
        """
        :param clean_up:    Perform clean-up procedure after encoding
        :param make_comp:   Create a slowpics-compatible comparison between src, flt, and enc
        """
        assert self.file.a_src

        v_encoder = X265Encoder(pick_settings(self.file), zones=zones)
        self.clip = dither_down(self.clip)

        audio_files = video_source(self.file.path.to_str(),
                                   trim_list=resolve_trims(
                                       self.file.trims_or_dfs),
                                   trims_framerate=self.file.clip.fps,
                                   flac=False,
                                   aac=True,
                                   silent=False)

        audio_tracks: List[AudioStream] = []
        for track in audio_files:
            audio_tracks += [
                AudioStream(VPath(track), 'AAC 2.0', JAPANESE, XML_TAG)
            ]

        if self.chapter_list:
            assert self.file.chapter
            assert self.file.trims_or_dfs

            if not isinstance(self.chapter_offset, int):
                self.chapter_offset = self.file.trims_or_dfs[
                    0] * -1  # type: ignore

            chapxml = MatroskaXMLChapters(self.file.chapter)
            chapxml.create(self.chapter_list, self.file.clip.fps)
            chapxml.shift_times(self.chapter_offset,
                                self.file.clip.fps)  # type: ignore
            chapxml.set_names(self.chapter_names)
            chapters = ChapterStream(chapxml.chapter_file, JAPANESE)

        muxer = Mux(self.file,
                    streams=(VideoStream(
                        self.file.name_clip_output,
                        'HEVC BDRip by LightArrowsEXE@Kaleido',
                        JAPANESE), audio_tracks,
                             chapters if self.chapter_list else None))

        config = RunnerConfig(v_encoder, None, None, None, None, muxer)

        runner = SelfRunner(self.clip, self.file, config)
        runner.run()

        try:
            if make_comp:
                generate_comparison(self.file,
                                    self.file.name_file_final.to_str(),
                                    self.clip)
        except ValueError as e:
            Status.fail(str(e))

        if clean_up:
            runner.do_cleanup()
            for at in audio_files:
                try:
                    os.remove(at)
                except FileNotFoundError:
                    Status.warn(f"File \"{at}\" not found! Skipping")
Exemplo n.º 20
0
    def run(self, clean_up: bool = True, make_comp: bool = True) -> None:
        """
        :param clean_up:    Perform clean-up procedure after encoding
        :param make_comp:   Create a slowpics-compatible comparison between src, flt, and enc
        """
        assert self.file.a_src

        is_dvd = False if self.file.clip.width > 1280 else True

        if is_dvd:
            Status.info("DVD encode detected: Switching over to DVD settings")
        x265_settings = 'settings/x265_settings' if not is_dvd else 'settings/x265_settings_dvd'
        msg = 'HEVC BDRip by LightArrowsEXE@Kaleido' if not is_dvd else 'HEVC DVDrip by LightArrowsEXE@Kaleido'

        v_encoder = X265Encoder(x265_settings)
        self.clip = dither_down(self.clip)

        audio_files = video_source(self.file.path.to_str(),
                                   trim_list=resolve_trims(
                                       self.file.trims_or_dfs),
                                   trims_framerate=self.file.clip.fps,
                                   flac=False,
                                   aac=True,
                                   silent=False)

        if not is_dvd:
            audio_tracks: List[AudioStream] = []
            for track in audio_files:
                audio_tracks += [
                    AudioStream(VPath(track), 'AAC 2.0', JAPANESE, XML_TAG)
                ]
        else:
            a_extracters = FfmpegAudioExtracter(self.file,
                                                track_in=0,
                                                track_out=0)
            a_cutters = EztrimCutter(self.file, track=1)
            audio_tracks = AudioStream(self.file.a_src_cut.set_track(1),
                                       'AC-3 2.0', JAPANESE)

        if self.chapter_list:
            assert self.file.chapter
            assert self.file.trims_or_dfs

            if not isinstance(self.chapter_offset, int):
                self.chapter_offset = self.file.trims_or_dfs[
                    0] * -1  # type: ignore

            chapxml = MatroskaXMLChapters(self.file.chapter)
            chapxml.create(self.chapter_list, self.file.clip.fps)
            chapxml.shift_times(self.chapter_offset,
                                self.file.clip.fps)  # type: ignore
            chapxml.set_names(self.chapter_names)
            chapters = ChapterStream(chapxml.chapter_file, JAPANESE)

        muxer = Mux(self.file,
                    streams=(VideoStream(self.file.name_clip_output, msg,
                                         JAPANESE), audio_tracks,
                             chapters if self.chapter_list else None))

        if not is_dvd:
            config = RunnerConfig(v_encoder, None, None, None, None, muxer)
        else:
            config = RunnerConfig(v_encoder, None, a_extracters, a_cutters,
                                  None, muxer)

        runner = SelfRunner(self.clip, self.file, config)
        runner.run()

        try:
            if make_comp:
                generate_comparison(self.file,
                                    self.file.name_file_final.to_str(),
                                    self.clip)
        except ValueError as e:
            Status.fail(str(e))

        if clean_up:
            runner.do_cleanup()