def do_encode(filtered): """Compression with x264""" print("Qpfile generating") vrf.gk(SRC_CUT, QPFILE) print("\n\n\nVideo encode") vrf.encode(filtered, X264, OUTPUT, **X264_ARGS) print("\n\n\nAudio extraction") eac3to_args = ['eac3to', SRC, '2:', A_SRC, '-log=NUL'] vrf.subprocess.run(eac3to_args, text=True, check=True, encoding='utf-8') print("\n\n\nAudio cut") eztrim(SRC_CLIP, (FRAME_START, FRAME_END), A_SRC, mkvextract_path="mkvextract") print("\n\n\nAudio encode") qaac_args = ['qaac64', A_SRC_CUT, '-V', '127', '--no-delay', '-o', A_ENC_CUT] vrf.subprocess.run(qaac_args, text=True, check=True, encoding='utf-8') print("\nFinal mux") mkv = MKVFile() mkv.add_track(MKVTrack(OUTPUT, language="jpn", default_track=True)) mkv.add_track(MKVTrack(A_ENC_CUT, language="jpn", default_track=True)) mkv.chapters(CHAPTER, "jpn") mkv.mux(OUTPUT_FINAL)
def do_encode(clip: vs.VideoNode)-> None: """Compression with x26X""" print('\n\n\nVideo encoding') vdf.encode(clip, 'x264', JPBD.output, **X264_ARGS, frames=clip.num_frames) print('\n\n\nAudio extraction') eac3to_args = ['eac3to', JPBD.src, '2:', JPBD.a_src, '-log=NUL'] subprocess.run(eac3to_args, text=True, check=True, encoding='utf-8') print('\n\n\nAudio cutting') eztrim(JPBD.src_clip, (JPBD.frame_start, JPBD.frame_end), JPBD.a_src, JPBD.a_src_cut.format(1)) print('\n\n\nAudio encoding') qaac_args = ['qaac', JPBD.a_src_cut.format(1), '-V', '127', '--no-delay', '-o', JPBD.a_enc_cut.format(1)] subprocess.run(qaac_args, text=True, check=True, encoding='utf-8') ffprobe_args = ['ffprobe', '-loglevel', 'quiet', '-show_entries', 'format_tags=encoder', '-print_format', 'default=nokey=1:noprint_wrappers=1', JPBD.a_enc_cut.format(1)] encoder_name = subprocess.check_output(ffprobe_args, shell=True, encoding='utf-8') f = open("tags_aac.xml", 'w') f.writelines(['<?xml version="1.0"?>', '<Tags>', '<Tag>', '<Targets>', '</Targets>', '<Simple>', '<Name>ENCODER</Name>', f'<String>{encoder_name}</String>', '</Simple>', '</Tag>', '</Tags>']) f.close() print('\nFinal muxing') mkv_args = ['mkvmerge', '-o', JPBD.output_final, '--track-name', '0:AVC BDRip par Vardë@Owlolf', '--language', '0:jpn', JPBD.output, '--tags', '0:tags_aac.xml', '--track-name', '0:AAC 2.0', '--language', '0:jpn', JPBD.a_enc_cut.format(1)] subprocess.run(mkv_args, text=True, check=True, encoding='utf-8') _ = [os.remove(f) for f in [JPBD.a_src, JPBD.a_src_cut.format(1), JPBD.a_enc_cut.format(1), 'tags_aac.xml']]
def do_encode(filtered): """Compression with x264""" print('Qpfile generating') vdf.gk(SRC_CUT, QPFILE) print('\n\n\nVideo encode') vdf.encode(filtered, X264, OUTPUT, **X264_ARGS) print('\n\n\nAudio extraction') mka = MKVFile() mka.add_track(MKVTrack(SRC, 1)) mka.mux(A_SRC) print('\n\n\nAudio cut') eztrim(SRC_CLIP, (FRAME_START, FRAME_END), A_SRC, mkvextract_path='mkvextract') print('\n\n\nAudio encode') qaac_args = [ 'qaac64', A_SRC_CUT, '-V', '127', '--no-delay', '-o', A_ENC_CUT ] vdf.subprocess.run(qaac_args, text=True, check=True, encoding='utf-8') print('\nFinal mux') mkv = MKVFile() mkv.add_track(MKVTrack(OUTPUT, language='jpn', default_track=True)) mkv.add_track(MKVTrack(A_ENC_CUT, language='jpn', default_track=True)) mkv.chapters(CHAPTER, 'jpn') mkv.mux(OUTPUT_FINAL)
def do_encode(clip: vs.VideoNode)-> None: """Compression with x26X""" if not os.path.exists(JPBD.output): print('\n\n\nVideo encoding') vdf.encode(clip, 'x264', JPBD.output, **X264_ARGS, frames=clip.num_frames) if not os.path.exists(JPBD.a_src): print('\n\n\nAudio extraction') eac3to_args = ['eac3to', JPBD.src, '2:', JPBD.a_src, '-log=NUL'] subprocess.run(eac3to_args, text=True, check=True, encoding='utf-8') if not os.path.exists(JPBD.a_src_cut.format(1)): print('\n\n\nAudio cutting') eztrim(JPBD.src_clip, (JPBD.frame_start, JPBD.frame_end), JPBD.a_src, JPBD.a_src_cut.format(1)) if not os.path.exists(JPBD.a_enc_cut.format(1)): print('\n\n\nAudio encoding') qaac_args = ['ffmpeg', '-i', JPBD.a_src_cut.format(1), '-compression_level', '12', '-lpc_type', 'cholesky', '-lpc_passes', '3', '-exact_rice_parameters', '1', JPBD.a_enc_cut.format(1)] subprocess.run(qaac_args, text=True, check=True, encoding='utf-8') if not os.path.exists(JPBD.output_final): print('\nFinal muxing') mkv_args = ['mkvmerge', '-o', JPBD.output_final, '--track-name', '0:AVC BDRip by Vardë@Raws-Maji', '--language', '0:jpn', JPBD.output, '--track-name', '0:FLAC 2.0', '--language', '0:jpn', JPBD.a_enc_cut.format(1)] subprocess.run(mkv_args, text=True, check=True, encoding='utf-8') # Clean up files = [JPBD.a_src, JPBD.a_src_cut.format(1), JPBD.a_enc_cut.format(1)] for file in files: if os.path.exists(file): os.remove(file)
def do_encode(filtered): """Compression with x264""" print('Qpfile generating') vdf.gk(JPBD.src_cut, JPBD.qpfile) print('\n\n\nVideo encode') vdf.encode(filtered, X264, JPBD.output, **X264_ARGS)
def do_encode(filtered): """Compression with x264""" print('Qpfile generating') vdf.gk(JPBD.src_cut, JPBD.qpfile) print('\n\n\nVideo encoding') vdf.encode(filtered, X264, JPBD.output, **X264_ARGS) print('\n\n\nAudio extraction') track_01 = USBD.a_src + '_eng.w64' track_02 = USBD.a_src + '_jpn.w64' eac3to_args = ['eac3to', USBD.src, '3:', track_01, '4:', track_02, '-log=NUL'] vdf.subprocess.run(eac3to_args, text=True, check=True, encoding='utf-8') mka = MKVFile() mka.add_track(MKVTrack(track_01, 0)) mka.add_track(MKVTrack(track_02, 0)) mka.mux(USBD.a_src) print('\n\n\nAudio cutting') eztrim(USBD.src_clip, (USBD.frame_start, USBD.frame_end), USBD.a_src, mkvextract_path='mkvextract') print('\n\n\nAudio encoding') for i in range(1, len(mka.tracks) + 1): qaac_args = ['qaac64', USBD.a_src_cut.format(i), '-V', '127', '--no-delay', '-o', USBD.a_enc_cut.format(i)] vdf.subprocess.run(qaac_args, text=True, check=True, encoding='utf-8') print('\nFinal muxing') mkv = MKVFile() mkv.add_track(MKVTrack(JPBD.output, language='jpn', default_track=True)) mkv.add_track(MKVTrack(USBD.a_enc_cut.format(2), language='jpn', default_track=True)) mkv.add_track(MKVTrack(USBD.a_enc_cut.format(1), language='eng', default_track=False)) mkv.mux(JPBD.output_final)
def do_encode(filtered): """Compression with x264""" print('\n\n\nVideo encoding') vdf.encode(filtered, X264, OUTPUT, True, **X264_ARGS, frames=filtered.num_frames) print('\n\n\nAudio extracting') mka = MKVFile() mka.add_track(MKVTrack(VIDEO_FILES[1], 1)) mka.mux(AUDIO_SRC) print('\n\n\nAudio cutting') eztrim(CLIPS_SRC[1], (0, 1), AUDIO_SRC, outfile=NAME + '_a', ffmpeg_path='') eztrim(CLIPS_SRC[1], (0, 0), AUDIO_SRC, outfile=NAME + '_b', ffmpeg_path='') print('\nFinal muxing') mkv_args = [ 'mkvmerge', '-o', NAME + '.mkv', '--language', '0:jpn', OUTPUT, '--language', '0:jpn', NAME + '_a' + '.mka', '+', NAME + '_b' + '.mka' ] vdf.subprocess.run(mkv_args, text=True, check=True, encoding='utf-8')
def do_encode(filtered): """Compression with x264""" print('Qpfile generating') vrf.gk(SRC_CUT, QPFILE) print('\n\n\nVideo encode') vrf.encode(filtered, X264, OUTPUT, **X264_ARGS) print('\n\n\nAudio extraction') eac3to_args = ['eac3to', SRC, '2:', A_SRC, '-log=NUL'] vrf.subprocess.run(eac3to_args, text=True, check=True, encoding='utf-8') print('\n\n\nAudio cut') eztrim(SRC_CLIP, (FRAME_START, FRAME_END), A_SRC, mkvextract_path='mkvextract') print('\n\n\nAudio encode') flac_args = ['flac', A_SRC_CUT, '-8'] vrf.subprocess.run(flac_args, text=True, check=True, encoding='utf-8') print('\nFinal mux') mkv = MKVFile() mkv.add_track(MKVTrack(OUTPUT, language='jpn', default_track=True)) mkv.add_track( MKVTrack(A_SRC_CUT[:-3] + 'flac', language='jpn', default_track=True)) mkv.mux(OUTPUT_FINAL)
def do_encode(clip: vs.VideoNode) -> None: """Compression with x26X""" print('\n\n\nVideo encoding') vdf.encode(clip, 'x264', JPBD.output, **X264_ARGS) print('\n\n\nAudio cutting & encoding') qaac_args = [ '-V', '127', '--no-delay', '--no-optimize', '--ignorelength', '--threading', '--start', sec_to_time(JPBD.frame_start / (clip.fps_num / clip.fps_den)), '--end', sec_to_time((JPBD.src_clip.num_frames + JPBD.frame_end) / (clip.fps_num / clip.fps_den)) ] for i in range(1, 2 + 1): qaac_args_more = [ 'qaac', JPBD.a_src.format(i), *qaac_args, '-o', JPBD.a_enc_cut.format(i) ] subprocess.run(qaac_args_more, text=True, check=True, encoding='utf-8') ffprobe_args = [ 'ffprobe', '-loglevel', 'quiet', '-show_entries', 'format_tags=encoder', '-print_format', 'default=nokey=1:noprint_wrappers=1', JPBD.a_enc_cut.format(1) ] encoder_name = subprocess.check_output(ffprobe_args, shell=True, encoding='utf-8') fil = open("tags_aac.xml", 'w') fil.writelines([ '<?xml version="1.0"?>', '<Tags>', '<Tag>', '<Targets>', '</Targets>', '<Simple>', '<Name>ENCODER</Name>', f'<String>{encoder_name}</String>', '</Simple>', '</Tag>', '</Tags>' ]) fil.close() print('\nFinal muxing') mkv_args = [ 'mkvmerge', '-o', JPBD.output_final, '--track-name', '0:AVC BDRip par Vardë@Family-Desuyo', '--language', '0:jpn', JPBD.output, '--tags', '0:tags_aac.xml', '--track-name', '0:AAC 2.0 Musiques japonaises', '--language', '0:jpn', JPBD.a_enc_cut.format(1), '--tags', '0:tags_aac.xml', '--track-name', '0:AAC 5.1 Musiques japonaises', '--language', '0:jpn', JPBD.a_enc_cut.format(2), '--tags', '0:tags_aac.xml', '--track-name', '0:AAC 2.0 Musiques anglaises', '--language', '0:jpn', 'tenki_no_ko_eng_song_2.0.m4a', '--tags', '0:tags_aac.xml', '--track-name', '0:AAC 5.1 Musiques anglaises', '--language', '0:jpn', 'tenki_no_ko_eng_song_5.1.m4a', '--chapter-language', 'fr', '--chapters', JPBD.chapter ] subprocess.run(mkv_args, text=True, check=True, encoding='utf-8')
def do_encode(filtered): """Compression with x264""" print('Qpfile generating') vdf.gk(JPBD.src_cut, JPBD.qpfile) print('\n\n\nVideo encoding') vdf.encode(filtered, X264, JPBD.output, **X264_ARGS) print('\n\n\nAudio extraction') eac3to_args = ['eac3to', JPBD.src, '2:', JPBD.a_src, '-log=NUL'] subprocess.run(eac3to_args, text=True, check=True, encoding='utf-8') print('\n\n\nAudio cutting') eztrim(JPBD.src_clip, (JPBD.frame_start, JPBD.frame_end), JPBD.a_src, JPBD.a_src_cut.format(1)) print('\n\n\nAudio encoding') qaac_args = [ 'qaac', JPBD.a_src_cut.format(1), '-V', '127', '--no-delay', '-o', JPBD.a_enc_cut.format(1) + '.m4a' ] subprocess.run(qaac_args, text=True, check=True, encoding='utf-8') opus_args = [ 'opusenc', '--bitrate', '192', JPBD.a_src_cut.format(1), JPBD.a_enc_cut.format(1) + '.opus' ] subprocess.run(opus_args, text=True, check=True, encoding='utf-8') print('\nFinal muxing') mkv_args = [ 'mkvmerge', '-o', JPBD.name + '_aac.mkv', '--language', '0:jpn', JPBD.output, '--language', '0:jpn', JPBD.a_enc_cut.format(1) + '.m4a' ] subprocess.run(mkv_args, text=True, check=True, encoding='utf-8') mkv_args = [ 'mkvmerge', '-o', JPBD.name + '_opus.mkv', '--language', '0:jpn', JPBD.output, '--language', '0:jpn', JPBD.a_enc_cut.format(1) + '.opus' ] subprocess.run(mkv_args, text=True, check=True, encoding='utf-8')
def do_encode(filtered): """Compression with x264""" print('Qpfile generating') vdf.gk(JPBD.src_cut, JPBD.qpfile) print('\n\n\nVideo encoding') vdf.encode(filtered, X264, JPBD.output, **X264_ARGS) print('\n\n\nAudio extraction') eac3to_args = ['eac3to', JPBD.src, '2:', JPBD.a_src, '-log=NUL'] subprocess.run(eac3to_args, text=True, check=True, encoding='utf-8') print('\n\n\nAudio cutting') eztrim(JPBD.src_clip, (JPBD.frame_start, JPBD.frame_end), JPBD.a_src, JPBD.a_src_cut.format(1)) print('\n\n\nAudio encoding') qaac_args = [ 'qaac', JPBD.a_src_cut.format(1), '-V', '127', '--no-delay', '-o', JPBD.a_enc_cut.format(1) + '.m4a' ] subprocess.run(qaac_args, text=True, check=True, encoding='utf-8') ffprobe_args = [ 'ffprobe', '-loglevel', 'quiet', '-show_entries', 'format_tags=encoder', '-print_format', 'default=nokey=1:noprint_wrappers=1', JPBD.a_enc_cut.format(1) + '.m4a' ] encoder_name = subprocess.check_output(ffprobe_args, shell=True, encoding='utf-8') f = open("tags_aac.xml", 'w') f.writelines([ '<?xml version="1.0"?>', '<Tags>', '<Tag>', '<Targets>', '</Targets>', '<Simple>', '<Name>ENCODER</Name>', f'<String>{encoder_name}</String>', '</Simple>', '</Tag>', '</Tags>' ]) f.close() opus_args = [ 'opusenc', '--bitrate', '192', JPBD.a_src_cut.format(1), JPBD.a_enc_cut.format(1) + '.opus' ] subprocess.run(opus_args, text=True, check=True, encoding='utf-8') opus_args = ['opusenc', '-V'] encoder_name = subprocess.check_output(opus_args, shell=True, encoding='utf-8').splitlines()[0] f = open("tags_opus.xml", 'w') f.writelines([ '<?xml version="1.0"?>', '<Tags>', '<Tag>', '<Targets>', '</Targets>', '<Simple>', '<Name>ENCODER</Name>', f'<String>{encoder_name}, VBR 192k</String>', '</Simple>', '</Tag>', '</Tags>' ]) f.close() print('\nFinal muxing') mkv_args = [ 'mkvmerge', '-o', JPBD.name + '_aac.mkv', '--language', '0:jpn', JPBD.output, '--tags', '0:tags_aac.xml', '--language', '0:jpn', JPBD.a_enc_cut.format(1) + '.m4a' ] subprocess.run(mkv_args, text=True, check=True, encoding='utf-8') mkv_args = [ 'mkvmerge', '-o', JPBD.name + '_opus.mkv', '--language', '0:jpn', JPBD.output, '--tags', '0:tags_opus.xml', '--language', '0:jpn', JPBD.a_enc_cut.format(1) + '.opus' ] subprocess.run(mkv_args, text=True, check=True, encoding='utf-8') _ = [ os.remove(f) for f in [ JPBD.a_src, JPBD.a_src_cut.format(1), JPBD.a_enc_cut.format(1) + '.m4a', JPBD.a_enc_cut.format(1) + '.opus', 'tags_aac.xml', 'tags_opus.xml' ] ]
def do_encode(filtered): """Compression with x264""" print('Qpfile generating') vdf.gk(JPBD.src_cut, JPBD.qpfile) print('\n\n\nVideo encoding') vdf.encode(filtered, X264, JPBD.output, **X264_ARGS) print('\n\n\nAudio extraction') eac3to_args = [ 'eac3to', JPBD.src, '2:', JPBD.a_src.format(1), # '3:', JPBD.a_src.format(2), '-log=NUL' ] subprocess.run(eac3to_args, text=True, check=True, encoding='utf-8') print('\n\n\nAudio cutting & encoding') # for i in range(1, 2+1): for i in range(1, 1 + 1): eztrim(JPBD.src_clip, (JPBD.frame_start, JPBD.frame_end), JPBD.a_src.format(i), JPBD.a_src_cut.format(i)) # Encode in AAC qaac_args = [ 'qaac', JPBD.a_src_cut.format(i), '-V', '127', '--no-delay', '-o', JPBD.a_enc_cut.format(i) + '.m4a' ] subprocess.run(qaac_args, text=True, check=True, encoding='utf-8') # Encode in Opus opus_args = [ 'opusenc', '--bitrate', '192', JPBD.a_src_cut.format(i), JPBD.a_enc_cut.format(i) + '.opus' ] subprocess.run(opus_args, text=True, check=True, encoding='utf-8') # Blanck cut and encode eztrim(JPBD.src_clip, (0, ENDCARD_LENGTH), 'blank.wav', 'blank_cut.wav') qaac_args = [ 'qaac', 'blank_cut.wav', '-V', '127', '--no-delay', '-o', 'blank_cut.m4a' ] subprocess.run(qaac_args, text=True, check=True, encoding='utf-8') opus_args = [ 'opusenc', '--bitrate', '192', 'blank_cut.wav', 'blank_cut.opus' ] subprocess.run(opus_args, text=True, check=True, encoding='utf-8') # Recup encoder name ffprobe_args = [ 'ffprobe', '-loglevel', 'quiet', '-show_entries', 'format_tags=encoder', '-print_format', 'default=nokey=1:noprint_wrappers=1', JPBD.a_enc_cut.format(1) + '.m4a' ] encoder_name = subprocess.check_output(ffprobe_args, shell=True, encoding='utf-8') fil = open("tags_aac.xml", 'w') fil.writelines([ '<?xml version="1.0"?>', '<Tags>', '<Tag>', '<Targets>', '</Targets>', '<Simple>', '<Name>ENCODER</Name>', f'<String>{encoder_name}</String>', '</Simple>', '</Tag>', '</Tags>' ]) fil.close() opus_args = ['opusenc', '-V'] encoder_name = subprocess.check_output(opus_args, shell=True, encoding='utf-8').splitlines()[0] fil = open("tags_opus.xml", 'w') fil.writelines([ '<?xml version="1.0"?>', '<Tags>', '<Tag>', '<Targets>', '</Targets>', '<Simple>', '<Name>ENCODER</Name>', f'<String>{encoder_name}, VBR 192k</String>', '</Simple>', '</Tag>', '</Tags>' ]) fil.close() print('\nFinal muxing') mkv_args = [ 'mkvmerge', '-o', JPBD.name + '_aac.mkv', '--language', '0:jpn', '--track-name', '0:AVC BDRip by Vardë@YameteTomete', JPBD.output, '--tags', '0:tags_aac.xml', '--language', '0:jpn', '--track-name', '0:AAC 2.0', JPBD.a_enc_cut.format(1) + '.m4a', '+', 'blank_cut.m4a', # '--tags', '0:tags_aac.xml', '--language', '0:jpn', '--track-name', '0:AAC 2.0 Commentary', JPBD.a_enc_cut.format(2) + '.m4a', '+', 'blank_cut.m4a', '--chapter-language', 'en', '--chapters', JPBD.chapter ] subprocess.run(mkv_args, text=True, check=True, encoding='utf-8') mkv_args = [ 'mkvmerge', '-o', JPBD.name + '_opus.mkv', '--language', '0:jpn', '--track-name', '0:AVC BDRip by Vardë@YameteTomete', JPBD.output, '--tags', '0:tags_opus.xml', '--language', '0:jpn', '--track-name', '0:Opus 2.0', JPBD.a_enc_cut.format(1) + '.opus', '+', 'blank_cut.opus', # '--tags', '0:tags_opus.xml', '--language', '0:jpn', '--track-name', '0:Opus 2.0 Commentary', JPBD.a_enc_cut.format(2) + '.opus', '+', 'blank_cut.opus', '--chapter-language', 'en', '--chapters', JPBD.chapter ] subprocess.run(mkv_args, text=True, check=True, encoding='utf-8') # Clean up files = [ 'tags_aac.xml', 'tags_opus.xml', 'blank_cut.wav', 'blank_cut.m4a', 'blank_cut.opus' ] for file in files: if os.path.exists(file): os.remove(file) # for i in range(1, 2+1): for i in range(1, 1 + 1): files = [ JPBD.a_src.format(i), JPBD.a_src_cut.format(i), JPBD.a_enc_cut.format(i) + '.m4a', JPBD.a_enc_cut.format(i) + '.opus' ] for file in files: if os.path.exists(file): os.remove(file)
def do_encode(clip: vs.VideoNode): """Compression with x264""" vdf.encode(clip, X264, OUTPUT, **X264_ARGS, frames=clip.num_frames)