Performance improvements

This commit is contained in:
Jared-02 2021-10-19 13:25:05 +08:00 committed by GitHub
parent aff3544b9e
commit 8c4bef86df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 159 additions and 88 deletions

View File

@ -318,10 +318,15 @@ class Muxer(object):
def LanguageList(self): def LanguageList(self):
LanguageList = [ LanguageList = [
["Hindi", "hin", "hin", "Hindi"], ["Simplified Chinese", "zhoS", "chi", "Simplified Chinese"],
["Tamil", "tam", "tam", "Tamil"], ["Traditional Chinese", "zhoT", "chi", "Traditional Chinese"],
["Telugu", "tel", "tel", "Telugu"], ["Mandarin (Putonghua)", "zho", "zh-cmn", "Mandarin"],
["Mandarin (Guoyu)", "zho", "chi", "Chinese"],
["Cantonese", "zho", "zh-yue", "Cantonese"],
["Taiwanese", "zho", "zh-nan", "Minnan"],
["Chinese", "zho", "chi", "Chinese"],
["English", "eng", "eng", "English"], ["English", "eng", "eng", "English"],
["British English", "enGB", "eng", "British English"],
["Afrikaans", "af", "afr", "Afrikaans"], ["Afrikaans", "af", "afr", "Afrikaans"],
["Arabic", "ara", "ara", "Arabic"], ["Arabic", "ara", "ara", "Arabic"],
["Arabic (Syria)", "araSy", "ara", "Arabic Syria"], ["Arabic (Syria)", "araSy", "ara", "Arabic Syria"],
@ -348,16 +353,15 @@ class Muxer(object):
["Assamese", "asm", "asm", "Assamese"], ["Assamese", "asm", "asm", "Assamese"],
["Bengali", "ben", "ben", "Bengali"], ["Bengali", "ben", "ben", "Bengali"],
["Basque", "eus", "baq", "Basque"], ["Basque", "eus", "baq", "Basque"],
["British English", "enGB", "eng", "British English"],
["Bulgarian", "bul", "bul", "Bulgarian"], ["Bulgarian", "bul", "bul", "Bulgarian"],
["Cantonese", "None", "chi", "Cantonese"],
["Catalan", "cat", "cat", "Catalan"], ["Catalan", "cat", "cat", "Catalan"],
["Simplified Chinese", "zhoS", "chi", "Chinese Simplified"],
["Traditional Chinese", "zhoT", "chi", "Chinese Traditional"],
["Croatian", "hrv", "hrv", "Croatian"], ["Croatian", "hrv", "hrv", "Croatian"],
["Czech", "ces", "cze", "Czech"], ["Czech", "ces", "cze", "Czech"],
["Danish", "dan", "dan", "Danish"], ["Danish", "dan", "dan", "Danish"],
["Dutch", "nld", "dut", "Dutch"], ["Dutch", "nld", "dut", "Dutch"],
["Hindi", "hin", "hin", "Hindi"],
["Tamil", "tam", "tam", "Tamil"],
["Telugu", "tel", "tel", "Telugu"],
["Estonian", "est", "est", "Estonian"], ["Estonian", "est", "est", "Estonian"],
["Filipino", "fil", "fil", "Filipino"], ["Filipino", "fil", "fil", "Filipino"],
["Finnish", "fin", "fin", "Finnish"], ["Finnish", "fin", "fin", "Finnish"],
@ -496,8 +500,6 @@ class Muxer(object):
self.mkvmerge, self.mkvmerge,
"--output", "--output",
outputVideo, outputVideo,
"--title",
'RAB',
"(", "(",
inputVideo, inputVideo,
")", ")",
@ -585,7 +587,7 @@ class Muxer(object):
"--language", "--language",
f"0:{language_id}", f"0:{language_id}",
"--track-name", "--track-name",
f"0:Forced", f"0:{language_name} Forced",
"--forced-track", "--forced-track",
"0:yes", "0:yes",
"--default-track", "--default-track",
@ -604,7 +606,7 @@ class Muxer(object):
"--language", "--language",
f"0:{language_id}", f"0:{language_id}",
"--track-name", "--track-name",
f"0:SDH", f"0:{language_name} SDH",
"--forced-track", "--forced-track",
"0:no", "0:no",
"--default-track", "--default-track",

View File

@ -60,7 +60,7 @@ def __profiles(profile, addHEVCDO=False):
"hevc-main-L30-dash-cenc", "hevc-main-L30-dash-cenc",
"hevc-main10-L30-dash-cenc", "hevc-main10-L30-dash-cenc",
"hevc-main10-L30-dash-cenc-prk", "hevc-main10-L30-dash-cenc-prk",
"hevc-main-L31-dash-cenc" "hevc-main-L31-dash-cenc",
"hevc-main10-L31-dash-cenc", "hevc-main10-L31-dash-cenc",
"hevc-main10-L31-dash-cenc-prk", "hevc-main10-L31-dash-cenc-prk",
"hevc-main-L40-dash-cenc", "hevc-main-L40-dash-cenc",
@ -68,7 +68,7 @@ def __profiles(profile, addHEVCDO=False):
"hevc-main10-L40-dash-cenc-prk", "hevc-main10-L40-dash-cenc-prk",
"hevc-main-L41-dash-cenc", "hevc-main-L41-dash-cenc",
"hevc-main10-L41-dash-cenc", "hevc-main10-L41-dash-cenc",
"hevc-main10-L41-dash-cenc-prk" "hevc-main10-L41-dash-cenc-prk",
] ]
if addHEVCDO: if addHEVCDO:
profiles += [ profiles += [
@ -80,18 +80,16 @@ def __profiles(profile, addHEVCDO=False):
elif profile == 'HDR-10 KEYS': elif profile == 'HDR-10 KEYS':
profiles += [ profiles += [
"hevc-hdr-main10-L30-dash-cenc", 'hevc-hdr-main10-L30-dash-cenc',
"hevc-hdr-main10-L30-dash-cenc-prk", 'hevc-hdr-main10-L30-dash-cenc-prk',
"hevc-hdr-main10-L31-dash-cenc", 'hevc-hdr-main10-L31-dash-cenc',
"hevc-hdr-main10-L31-dash-cenc-prk", 'hevc-hdr-main10-L31-dash-cenc-prk',
"hevc-hdr-main10-L40-dash-cenc", 'hevc-hdr-main10-L40-dash-cenc',
"hevc-hdr-main10-L41-dash-cenc", 'hevc-hdr-main10-L40-dash-cenc-prk',
"hevc-hdr-main10-L40-dash-cenc-prk",
"hevc-hdr-main10-L41-dash-cenc-prk"
] ]
else: else:
profiles += [ profiles += [
"playready-h264mpl30-dash", "playready-h264mpl30-dash",
] ]
return profiles return profiles

View File

@ -19,14 +19,12 @@ def MSLprofiles():
"playready-h264mpl31-dash", "playready-h264mpl31-dash",
], ],
"FHD": [ "FHD": [
"playready-h264bpl30-dash",
"playready-h264mpl22-dash", "playready-h264mpl22-dash",
"playready-h264mpl30-dash", "playready-h264mpl30-dash",
"playready-h264mpl31-dash", "playready-h264mpl31-dash",
"playready-h264mpl40-dash", "playready-h264mpl40-dash",
], ],
"ALL": [ "ALL": [
"playready-h264bpl30-dash",
"playready-h264mpl22-dash", "playready-h264mpl22-dash",
"playready-h264mpl30-dash", "playready-h264mpl30-dash",
"playready-h264mpl31-dash", "playready-h264mpl31-dash",
@ -366,6 +364,7 @@ class get_manifest:
return VideoList return VideoList
def ParseVideo(self, resp, getHigh): def ParseVideo(self, resp, getHigh):
manifest = resp["result"] manifest = resp["result"]
VideoList = [] VideoList = []
checkerinfo = "" checkerinfo = ""
@ -410,21 +409,30 @@ class get_manifest:
if getHigh: if getHigh:
HighVideoList = self.HighVideoMSL() HighVideoList = self.HighVideoMSL()
if not HighVideoList == []: if not HighVideoList == []:
checkerinfo = "\nNetflix Profile Checker v1.0\nMAIN: {}kbps | {}\nHIGH: {}kbps | {}\n\n{}\n" # 判断high或main要求main比high的vamf更大的情况下选择main
# main和high的vamf相同时选择high
if int(dict(VideoList[-1])["vmaf"]) >= int(dict(HighVideoList[-1])["vmaf"]) and int(dict(VideoList[-1])["Bitrate"]) >= int(dict(HighVideoList[-1])["Bitrate"]):
check_high_or_main = "MAIN"
else: check_high_or_main = "HIGH"
checkerinfo = "\nNetflix Profile Checker v1.1\n2021-10-19 Jared_mod\n\nMain Rate: {}kbps | Vamf: {} | Profile: {}\nHigh Rate: {}kbps | Vamf: {} | Profile: {}\n\nResult: {} is Better!\n"
checkerinfo = checkerinfo.format( checkerinfo = checkerinfo.format(
str(dict(VideoList[-1])["Bitrate"]), str(dict(VideoList[-1])["Bitrate"]),
str(dict(VideoList[-1])["vmaf"]),
str(dict(VideoList[-1])["Profile"]), str(dict(VideoList[-1])["Profile"]),
str(dict(HighVideoList[-1])["Bitrate"]), str(dict(HighVideoList[-1])["Bitrate"]),
str(dict(HighVideoList[-1])["vmaf"]),
str(dict(HighVideoList[-1])["Profile"]), str(dict(HighVideoList[-1])["Profile"]),
"result: MAIN is Better" check_high_or_main,
if int(dict(VideoList[-1])["Bitrate"])
>= int(dict(HighVideoList[-1])["Bitrate"])
else "result: HIGH is Better",
) )
VideoList += HighVideoList
self.logger.debug("HighVideoList: {}".format(HighVideoList)) self.logger.debug("HighVideoList: {}".format(HighVideoList))
if check_high_or_main == "MAIN":
# 合并main和high解析列表
VideoList += HighVideoList
elif check_high_or_main == "HIGH":
VideoList = HighVideoList
VideoList = sorted(VideoList, key=lambda k: int(k["Bitrate"])) VideoList = sorted(VideoList, key=lambda k: int(k["Bitrate"]))
return VideoList, checkerinfo return VideoList, checkerinfo

View File

@ -163,15 +163,11 @@ class aria2:
def aria2Options( def aria2Options(
self, self,
allow_overwrite=True, allow_overwrite=True,
file_allocation=None,
auto_file_renaming=False, auto_file_renaming=False,
async_dns=False, async_dns=False,
retry_wait=5, retry_wait=5,
summary_interval=0, enable_color=True,
enable_color=False, concurrent_downloads=5,
connection=16,
concurrent_downloads=16,
split=16,
header="skip", header="skip",
user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36", user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36",
uri_selector="inorder", uri_selector="inorder",
@ -179,51 +175,106 @@ class aria2:
download_result="hide", download_result="hide",
quiet="false", quiet="false",
extra_commands=[], extra_commands=[],
# 单服务器最大连接线程数
connection=64,
# 单任务最大连接线程数
split=64,
# 代理地址,根据需要修改
http_proxy_aria2c="http://127.0.0.1:7890",
https_proxy_aria2c="http://127.0.0.1:7890",
# 保存会话进度,用于断点续传
save_session_interval=1,
auto_save_interval=30,
force_save="false",
# 文件最小分段大小
min_split_size="4M",
# 磁盘缓存
max_tries="0",
# HTTP/FTP下载分片大小
piece_length="1M",
# 下载进度摘要输出间隔时间
summary_interval=0,
# 断点续传
continue_aria2c="true",
# 文件预分配方式 可选none, prealloc, trunc, falloc
# 机械硬盘falloc
# 固态硬盘none
# prealloc 分配速度慢, trunc 无实际作用,不推荐使用。
file_allocation="none",
# 磁盘缓存
disk_cache="64M",
): ):
options = [] + extra_commands options = [] + extra_commands
allow_overwrite = self.convert_args(allow_overwrite) allow_overwrite = self.convert_args(allow_overwrite)
quiet = self.convert_args(quiet) quiet = self.convert_args(quiet)
file_allocation = self.convert_args(file_allocation)
auto_file_renaming = self.convert_args(auto_file_renaming) auto_file_renaming = self.convert_args(auto_file_renaming)
async_dns = self.convert_args(async_dns) async_dns = self.convert_args(async_dns)
retry_wait = self.convert_args(retry_wait) retry_wait = self.convert_args(retry_wait)
enable_color = self.convert_args(enable_color) enable_color = self.convert_args(enable_color)
connection = self.convert_args(connection)
concurrent_downloads = self.convert_args(concurrent_downloads) concurrent_downloads = self.convert_args(concurrent_downloads)
split = self.convert_args(split)
header = self.convert_args(header) header = self.convert_args(header)
user_agent = self.convert_args(user_agent)
uri_selector = self.convert_args(uri_selector) uri_selector = self.convert_args(uri_selector)
console_log_level = self.convert_args(console_log_level) console_log_level = self.convert_args(console_log_level)
download_result = self.convert_args(download_result) download_result = self.convert_args(download_result)
connection = self.convert_args(connection)
split = self.convert_args(split)
http_proxy_aria2c = self.convert_args(http_proxy_aria2c)
https_proxy_aria2c = self.convert_args(https_proxy_aria2c)
save_session_interval = self.convert_args(save_session_interval)
auto_save_interval = self.convert_args(auto_save_interval)
force_save = self.convert_args(force_save)
min_split_size = self.convert_args(min_split_size)
max_tries = self.convert_args(max_tries)
piece_length = self.convert_args(piece_length)
summary_interval = self.convert_args(summary_interval)
continue_aria2c = self.convert_args(continue_aria2c)
file_allocation = self.convert_args(file_allocation)
disk_cache = self.convert_args(disk_cache)
############################################################################## ##############################################################################
options += self.append_commands(options, "--allow-overwrite=", allow_overwrite) options += self.append_commands(options, "--allow-overwrite=", allow_overwrite)
options += self.append_commands(options, "--quiet=", quiet) options += self.append_commands(options, "--quiet=", quiet)
options += self.append_commands(options, "--file-allocation=", file_allocation)
options += self.append_commands( options += self.append_commands(
options, "--auto-file-renaming=", auto_file_renaming options, "--auto-file-renaming=", auto_file_renaming
) )
options += self.append_commands(options, "--async-dns=", async_dns) options += self.append_commands(options, "--async-dns=", async_dns)
options += self.append_commands(options, "--retry-wait=", retry_wait) options += self.append_commands(options, "--retry-wait=", retry_wait)
options += self.append_commands(options, "--enable-color=", enable_color) options += self.append_commands(options, "--enable-color=", enable_color)
options += self.append_commands(
options, "--max-connection-per-server=", connection
)
options += self.append_commands( options += self.append_commands(
options, "--max-concurrent-downloads=", concurrent_downloads options, "--max-concurrent-downloads=", concurrent_downloads
) )
options += self.append_commands(options, "--split=", split)
options += self.append_commands(options, "--header=", header) options += self.append_commands(options, "--header=", header)
options += self.append_commands(options, "--user-agent=", user_agent)
options += self.append_commands(options, "--uri-selector=", uri_selector) options += self.append_commands(options, "--uri-selector=", uri_selector)
options += self.append_commands( options += self.append_commands(
options, "--console-log-level=", console_log_level options, "--console-log-level=", console_log_level
) )
options += self.append_commands(options, "--download-result=", download_result) options += self.append_commands(options, "--download-result=", download_result)
options += self.append_commands(
options, "--max-connection-per-server=", connection
)
options += self.append_commands(options, "--split=", split)
options += self.append_commands(options, "--http-proxy=", http_proxy_aria2c)
options += self.append_commands(options, "--https-proxy=", https_proxy_aria2c)
options += self.append_commands(options, "--save-session-interval=", save_session_interval)
options += self.append_commands(options, "--auto-save-interval=", auto_save_interval)
options += self.append_commands(options, "--force-save=", force_save)
options += self.append_commands(options, "--min-split-size=", min_split_size)
options += self.append_commands(options, "--max-tries=", max_tries)
options += self.append_commands(options, "--piece-length=", piece_length)
options += self.append_commands(options, "--summary-interval=", summary_interval)
options += self.append_commands(options, "--continue=", continue_aria2c)
options += self.append_commands(options, "--file-allocation=", file_allocation)
options += self.append_commands(options, "--disk-cache=", disk_cache)
return options return options
def aria2DisableProxies(self): def aria2DisableProxies(self):

View File

@ -386,6 +386,10 @@ class ripprocess(object):
return "Mandarin Chinese (Simplified)", "zh-Hans" return "Mandarin Chinese (Simplified)", "zh-Hans"
elif code == "cmn-Hant": elif code == "cmn-Hant":
return "Mandarin Chinese (Traditional)", "zh-Hant" return "Mandarin Chinese (Traditional)", "zh-Hant"
elif code == "zh-TW":
return "Chinese", "zho"
elif code == "zh-CN":
return "Chinese", "zho"
elif code == "es-419": elif code == "es-419":
return "Spanish", "spa" return "Spanish", "spa"
elif code == "es-ES": elif code == "es-ES":
@ -674,16 +678,18 @@ class ripprocess(object):
outputName = inputName.replace(replace_str, ext) outputName = inputName.replace(replace_str, ext)
self.logger.info(("{} -> {}").format(inputName, outputName)) self.logger.info(("{} -> {}").format(inputName, outputName))
ff = ffmpy.FFmpeg( #直接重命名到目标格式移除ffmpeg混流过程
executable=self.bin["ffmpeg"], os.rename(inputName, outputName)
inputs={inputName: None}, #ff = ffmpy.FFmpeg(
outputs={outputName: "-c:a copy"}, # executable=self.bin["ffmpeg"],
global_options="-vn -sn -y -hide_banner -loglevel panic", # inputs={inputName: None},
) # outputs={outputName: "-c:a copy"},
ff.run() # global_options="-vn -sn -y -hide_banner -loglevel panic",
time.sleep(0.05) #)
if os.path.isfile(outputName) and os.path.getsize(outputName) > 1024 * 1024: #ff.run()
os.remove(inputName) #time.sleep(0.05)
#if os.path.isfile(outputName) and os.path.getsize(outputName) > 1024 * 1024:
# os.remove(inputName)
self.logger.info("Done!") self.logger.info("Done!")
return return

View File

@ -299,7 +299,10 @@ class netflix:
def downloadFile2(self, url, file_name): def downloadFile2(self, url, file_name):
with open(file_name, "wb") as f: with open(file_name, "wb") as f:
response = requests.get(url, stream=True) #避免ssl错误卡死关闭requests模块ssl证书验证verify=False
#关闭后,控制台持续输出警告,建议开启证书验证,取消注释下行代码可以屏蔽
#requests.packages.urllib3.diable_warnings()
response = requests.get(url, stream=True, verify=False)
#response.encoding = 'UTF-8' #response.encoding = 'UTF-8'
f.write(response.content) f.write(response.content)
@ -320,10 +323,7 @@ class netflix:
async_dns="skip", async_dns="skip",
retry_wait=5, retry_wait=5,
summary_interval=0, summary_interval=0,
enable_color=True, concurrent_downloads=5,
connection=16,
concurrent_downloads=16,
split=16,
uri_selector="inorder", uri_selector="inorder",
console_log_level="warn", console_log_level="warn",
download_result="hide", download_result="hide",
@ -389,17 +389,19 @@ class netflix:
return "DDP5.1" return "DDP5.1"
def RemuxVideo(self, outputVideoTemp, outputVideo, Name): def RemuxVideo(self, outputVideoTemp, outputVideo, Name):
self.logger.info("\nRemuxing video...") #self.logger.info("\nRemuxing video...")
ff = ffmpy.FFmpeg( #ff = ffmpy.FFmpeg(
executable=self.bin["ffmpeg"], # executable=self.bin["ffmpeg"],
inputs={outputVideoTemp: None}, # inputs={outputVideoTemp: None},
outputs={outputVideo: "-c copy"}, # outputs={outputVideo: "-c copy"},
global_options="-y -hide_banner -loglevel warning", # global_options="-y -hide_banner -loglevel warning",
) #)
#ff.run()
#time.sleep(50.0 / 1000.0)
#os.remove(outputVideoTemp)
ff.run() #解密视频文件直接重命名移除ffmpeg混流过程
time.sleep(50.0 / 1000.0) os.rename(outputVideoTemp, outputVideo)
os.remove(outputVideoTemp)
self.logger.info("Done!") self.logger.info("Done!")
return True return True
@ -461,6 +463,7 @@ class netflix:
if not only1key == []: if not only1key == []:
KEYS = only1key KEYS = only1key
# 未解密视频传递ripprocess模块解密
self.ripprocess.mp4_decrypt( self.ripprocess.mp4_decrypt(
encrypted=inputVideo, encrypted=inputVideo,
decrypted=outputVideoTemp, decrypted=outputVideoTemp,
@ -470,18 +473,21 @@ class netflix:
silent=silent, silent=silent,
) )
if not "NETFLIX".lower() in list( #不理解这个模块的判断逻辑操作是把解密的视频传入ffmpeg重新封装
map(lambda x: x.lower(), self.video_settings["skip_video_demux"]) #if not "NETFLIX".lower() in list(
): # map(lambda x: x.lower(), self.video_settings["skip_video_demux"])
self.ripprocess.DemuxVideo( #):
outputVideoTemp=outputVideoTemp, # self.ripprocess.DemuxVideo(
outputVideo=outputVideo, # outputVideoTemp=outputVideoTemp,
ffmpeg=True, # outputVideo=outputVideo,
mp4box=False, # ffmpeg=True,
) # mp4box=False,
else: # )
os.rename(outputVideoTemp, outputVideo) #else:
# os.rename(outputVideoTemp, outputVideo)
#移除判断,解密后视频文件直接重命名
os.rename(outputVideoTemp, outputVideo)
return True return True
def SubtitleThreader(self, subtitlesList, name): def SubtitleThreader(self, subtitlesList, name):