Compare commits
2 Commits
linux-fixe
...
479ac49796
| Author | SHA1 | Date | |
|---|---|---|---|
| 479ac49796 | |||
| edd4f14d32 |
@@ -24,9 +24,9 @@ def _encode_video(
|
|||||||
print(f'Encoding {preset['h']}p AV1')
|
print(f'Encoding {preset['h']}p AV1')
|
||||||
|
|
||||||
cmd = [
|
cmd = [
|
||||||
"ffmpeg", "-v", "quiet", "-stats",
|
"ffmpeg",
|
||||||
"-i", f'"{preset['input_video']}"',
|
"-i", preset['input_video'],
|
||||||
"-i", f'"{source_video}"',
|
"-i", source_video,
|
||||||
"-map", "0:v:0", # Video from upscale or interpolated file
|
"-map", "0:v:0", # Video from upscale or interpolated file
|
||||||
"-map", "1:a:0", # Audio from source video
|
"-map", "1:a:0", # Audio from source video
|
||||||
"-map", "1:s:0", # Subtitle from source video
|
"-map", "1:s:0", # Subtitle from source video
|
||||||
@@ -38,16 +38,15 @@ def _encode_video(
|
|||||||
"-crf", preset['crf'],
|
"-crf", preset['crf'],
|
||||||
"-preset", "4",
|
"-preset", "4",
|
||||||
"-pix_fmt", "yuv420p10le", # 10bit
|
"-pix_fmt", "yuv420p10le", # 10bit
|
||||||
"-vf", f"\"scale=\'min({preset['w']},iw)\':-2,setsar=1:1\"",
|
"-vf", f"scale=\'min({preset['w']},iw)\':-2,setsar=1:1",
|
||||||
"-aspect", input_aspect,
|
"-aspect", input_aspect,
|
||||||
"-c:a", "libopus",
|
"-c:a", "libopus",
|
||||||
"-b:a", "160k",
|
"-b:a", "160k",
|
||||||
"-c:s", "copy",
|
"-c:s", "copy",
|
||||||
f'"{output_video}"'
|
output_video
|
||||||
]
|
]
|
||||||
|
|
||||||
if sys.platform == 'linux':
|
print(cmd)
|
||||||
cmd = ' '.join(cmd)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subprocess.run(cmd, shell=True, check=True)
|
subprocess.run(cmd, shell=True, check=True)
|
||||||
@@ -65,13 +64,13 @@ def encode_downloads(
|
|||||||
input_aspect: str = "16:9"
|
input_aspect: str = "16:9"
|
||||||
):
|
):
|
||||||
presets = [
|
presets = [
|
||||||
{"w": "1920", "h": "1080", "crf": "22", "name": "[1080p-AV1]", "input_video": upscaled_video},
|
{"w": "1920", "h": "1080", "crf": "24", "name": "[1080p-AV1]", "input_video": upscaled_video},
|
||||||
{"w": "1920", "h": "1080", "crf": "22", "name": "[1080p-AV1][48fps]", "input_video": interpolated_video},
|
{"w": "1920", "h": "1080", "crf": "24", "name": "[1080p-AV1][48fps]", "input_video": interpolated_video},
|
||||||
{"w": "3840", "h": "2160", "crf": "24", "name": "[2160p-AV1]", "input_video": upscaled_video},
|
{"w": "3840", "h": "2160", "crf": "26", "name": "[2160p-AV1]", "input_video": upscaled_video},
|
||||||
]
|
]
|
||||||
|
|
||||||
if interpolated_uhd_video is not None:
|
if interpolated_uhd_video is not None:
|
||||||
presets.append({"w": "3840", "h": "2160", "crf": "24", "name": "[2160p-AV1][48fps]", "input_video": interpolated_uhd_video})
|
presets.append({"w": "3840", "h": "2160", "crf": "26", "name": "[2160p-AV1][48fps]", "input_video": interpolated_uhd_video})
|
||||||
|
|
||||||
for preset in presets:
|
for preset in presets:
|
||||||
file_name = f"{hentai_title} {preset['name']}[hstream.moe].mkv"
|
file_name = f"{hentai_title} {preset['name']}[hstream.moe].mkv"
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ def _encode_720p_fallback(
|
|||||||
|
|
||||||
cmd = [
|
cmd = [
|
||||||
"ffmpeg", "-v", "quiet", "-stats",
|
"ffmpeg", "-v", "quiet", "-stats",
|
||||||
"-i", f'"{upscale_output}"',
|
"-i", upscale_output,
|
||||||
"-i", f'"{video_source}"',
|
"-i", video_source,
|
||||||
"-map", "0:v:0",
|
"-map", "0:v:0",
|
||||||
"-map", "1:a:0",
|
"-map", "1:a:0",
|
||||||
"-c:v", "libx264",
|
"-c:v", "libx264",
|
||||||
@@ -65,12 +65,9 @@ def _encode_720p_fallback(
|
|||||||
"-sn",
|
"-sn",
|
||||||
"-map_metadata", "-1",
|
"-map_metadata", "-1",
|
||||||
"-movflags", "+faststart",
|
"-movflags", "+faststart",
|
||||||
f'"{output}"'
|
output
|
||||||
]
|
]
|
||||||
|
|
||||||
if sys.platform == 'linux':
|
|
||||||
cmd = ' '.join(cmd)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subprocess.run(cmd, shell=True, check=True)
|
subprocess.run(cmd, shell=True, check=True)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
@@ -138,8 +135,8 @@ def _encode(
|
|||||||
|
|
||||||
cmd = [
|
cmd = [
|
||||||
"ffmpeg", "-v", "quiet", "-stats",
|
"ffmpeg", "-v", "quiet", "-stats",
|
||||||
"-i", f'"{preset['input_video']}"',
|
"-i", preset['input_video'],
|
||||||
"-i", f'"{source_video}"',
|
"-i", source_video,
|
||||||
"-map", "0:v:0", # Video from Upscale
|
"-map", "0:v:0", # Video from Upscale
|
||||||
"-map", "1:a:0", # Audio from Source
|
"-map", "1:a:0", # Audio from Source
|
||||||
"-c:v", preset['encoder'],
|
"-c:v", preset['encoder'],
|
||||||
@@ -152,17 +149,10 @@ def _encode(
|
|||||||
|
|
||||||
if preset["encoder"] == "libx264":
|
if preset["encoder"] == "libx264":
|
||||||
cmd += ["-x264-params", f"keyint=24:min-keyint=24:scenecut=0"]
|
cmd += ["-x264-params", f"keyint=24:min-keyint=24:scenecut=0"]
|
||||||
cmd += ["-c:a", "aac", "-b:a", "128k"]
|
cmd += ["-c:a", "aac", "-b:a", "160k"]
|
||||||
elif preset["encoder"] == "libsvtav1":
|
elif preset["encoder"] == "libsvtav1":
|
||||||
cmd += ["-svtav1-params", f"keyint={keyframe_interval}s,fast-decode=1,tune=0"]
|
cmd += ["-svtav1-params", f"keyint={keyframe_interval}s,fast-decode=1,tune=0"]
|
||||||
cmd += ["-c:a", "libopus", "-b:a", "128k"]
|
cmd += ["-c:a", "aac", "-b:a", "160k"]
|
||||||
|
|
||||||
init_seg_name = "chunks/init-stream$RepresentationID$.webm"
|
|
||||||
media_seg_name = "chunks/chunk-stream$RepresentationID$-$Number%05d$.webm"
|
|
||||||
|
|
||||||
if sys.platform == 'linux':
|
|
||||||
init_seg_name = "chunks/init-stream\$RepresentationID\$.webm"
|
|
||||||
media_seg_name = "chunks/chunk-stream\$RepresentationID\$-\$Number%05d\$.webm"
|
|
||||||
|
|
||||||
cmd += [
|
cmd += [
|
||||||
"-ac", "2",
|
"-ac", "2",
|
||||||
@@ -170,15 +160,14 @@ def _encode(
|
|||||||
"-map_metadata", "-1", # Get rid of metadata which might be incorrect
|
"-map_metadata", "-1", # Get rid of metadata which might be incorrect
|
||||||
"-use_template", "1", # Don't list every segment url, use template instead
|
"-use_template", "1", # Don't list every segment url, use template instead
|
||||||
"-use_timeline", "1", # Make sure segment timing is always correct
|
"-use_timeline", "1", # Make sure segment timing is always correct
|
||||||
"-init_seg_name", init_seg_name, # Init segment
|
"-init_seg_name", "chunks/init-stream$RepresentationID$.webm", # Init segment
|
||||||
"-media_seg_name", media_seg_name, # Media segments
|
"-media_seg_name", "chunks/chunk-stream$RepresentationID$-$Number%05d$.webm", # Media segments
|
||||||
"-seg_duration", str(segment_duration), # DASH segment duration
|
"-seg_duration", str(segment_duration), # DASH segment duration
|
||||||
"-f", "dash",
|
"-f", "dash",
|
||||||
f'"{os.path.join(cdn_folder, preset['out_folder'], 'manifest.mpd')}"'
|
os.path.join(cdn_folder, preset['out_folder'], 'manifest.mpd')
|
||||||
]
|
]
|
||||||
|
|
||||||
if sys.platform == 'linux':
|
print(cmd)
|
||||||
cmd = ' '.join(cmd)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subprocess.run(cmd, shell=True, check=True)
|
subprocess.run(cmd, shell=True, check=True)
|
||||||
|
|||||||
@@ -26,9 +26,6 @@ def _create_vsrife_script(
|
|||||||
script = [
|
script = [
|
||||||
'import vapoursynth as vs',
|
'import vapoursynth as vs',
|
||||||
'from vsrife import rife',
|
'from vsrife import rife',
|
||||||
# this isn't a real fix, as this SHOULDN'T FIX IT
|
|
||||||
# however for some reason it does
|
|
||||||
'vs.core.max_cache_size=8192',
|
|
||||||
f'clip = vs.core.ffms2.Source(source="./{hentai_name} [4k][HEVC].mkv")',
|
f'clip = vs.core.ffms2.Source(source="./{hentai_name} [4k][HEVC].mkv")',
|
||||||
f'clip = vs.core.resize.Bicubic(clip, width={video_width}, height=2160, format=vs.RGBS, matrix_in_s="709")',
|
f'clip = vs.core.resize.Bicubic(clip, width={video_width}, height=2160, format=vs.RGBS, matrix_in_s="709")',
|
||||||
'clip = rife(clip=clip, model="4.25.lite", factor_num=2, factor_den=1)',
|
'clip = rife(clip=clip, model="4.25.lite", factor_num=2, factor_den=1)',
|
||||||
@@ -46,18 +43,15 @@ def _interpolate(
|
|||||||
cmd = [
|
cmd = [
|
||||||
"vspipe",
|
"vspipe",
|
||||||
"-c", "y4m",
|
"-c", "y4m",
|
||||||
f'"{vapoursynth_file}"',
|
vapoursynth_file,
|
||||||
"-", "|",
|
"-", "|",
|
||||||
"ffmpeg", "-v", "quiet", "-stats",
|
"ffmpeg", "-v", "quiet", "-stats",
|
||||||
"-i", "-",
|
"-i", "-",
|
||||||
"-c:v", "hevc_nvenc",
|
"-c:v", "hevc_nvenc",
|
||||||
"-qp", "5",
|
"-qp", "5",
|
||||||
f'"{interpolate_output}"'
|
interpolate_output
|
||||||
]
|
]
|
||||||
|
|
||||||
if sys.platform == 'linux':
|
|
||||||
cmd = ' '.join(cmd)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subprocess.run(cmd, shell=True, check=True)
|
subprocess.run(cmd, shell=True, check=True)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ def _re_encode(
|
|||||||
|
|
||||||
cmd = [
|
cmd = [
|
||||||
"ffmpeg", "-v", "quiet", "-stats",
|
"ffmpeg", "-v", "quiet", "-stats",
|
||||||
"-i", f'"{source_video}"',
|
"-i", source_video,
|
||||||
"-c:v", "ffv1",
|
"-c:v", "ffv1",
|
||||||
"-level", "3",
|
"-level", "3",
|
||||||
"-vf", f"\"fps={get_framerate(source_video)},scale=-1:\'min({MAX_INPUT_WIDTH},ih)\'\"",
|
"-vf", f"fps={get_framerate(source_video)},scale=-1:\'min({MAX_INPUT_WIDTH},ih)\'",
|
||||||
"-aspect", input_aspect,
|
"-aspect", input_aspect,
|
||||||
"-pix_fmt", "yuv420p",
|
"-pix_fmt", "yuv420p",
|
||||||
"-color_primaries", "1",
|
"-color_primaries", "1",
|
||||||
@@ -34,12 +34,9 @@ def _re_encode(
|
|||||||
"-an",
|
"-an",
|
||||||
"-sn",
|
"-sn",
|
||||||
"-map_metadata", "-1",
|
"-map_metadata", "-1",
|
||||||
f'"{temp_out_video}"'
|
temp_out_video
|
||||||
]
|
]
|
||||||
|
|
||||||
if sys.platform == 'linux':
|
|
||||||
cmd = ' '.join(cmd)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subprocess.run(cmd, shell=True, check=True)
|
subprocess.run(cmd, shell=True, check=True)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
@@ -57,7 +54,7 @@ def _upscale(
|
|||||||
cmd = [
|
cmd = [
|
||||||
"vspipe",
|
"vspipe",
|
||||||
"-c", "y4m",
|
"-c", "y4m",
|
||||||
f"\"{vapoursynth_script}\"",
|
vapoursynth_script,
|
||||||
"-", # Video output to pipe
|
"-", # Video output to pipe
|
||||||
"|", # Pipe
|
"|", # Pipe
|
||||||
"ffmpeg", "-v", "quiet", "-stats",
|
"ffmpeg", "-v", "quiet", "-stats",
|
||||||
@@ -66,12 +63,9 @@ def _upscale(
|
|||||||
"-c:v", "hevc_nvenc",
|
"-c:v", "hevc_nvenc",
|
||||||
"-qp", "5",
|
"-qp", "5",
|
||||||
"-aspect", input_aspect,
|
"-aspect", input_aspect,
|
||||||
f"\"{upscale_output}\""
|
upscale_output
|
||||||
]
|
]
|
||||||
|
|
||||||
if sys.platform == 'linux':
|
|
||||||
cmd = ' '.join(cmd)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subprocess.run(cmd, shell=True, check=True)
|
subprocess.run(cmd, shell=True, check=True)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user