fix: import path
This commit is contained in:
+6
-3
@@ -5,8 +5,7 @@ import time
|
|||||||
import subprocess
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
sys.path.append(str(Path(__file__).resolve().parent))
|
from core import BaseTranscoder
|
||||||
from transcode_core import BaseTranscoder
|
|
||||||
|
|
||||||
VIDEO_DEFAULTS = {
|
VIDEO_DEFAULTS = {
|
||||||
"libx265": ["-preset", "slow", "-pix_fmt", "yuv420p10le", "-x265-params", "aq-mode=3:aq-strength=0.8:psy-rd=1.0"],
|
"libx265": ["-preset", "slow", "-pix_fmt", "yuv420p10le", "-x265-params", "aq-mode=3:aq-strength=0.8:psy-rd=1.0"],
|
||||||
@@ -19,6 +18,7 @@ AUDIO_DEFAULTS = {
|
|||||||
"opus": ["-c:a", "libopus", "-b:a", "128k", "-vbr", "on"],
|
"opus": ["-c:a", "libopus", "-b:a", "128k", "-vbr", "on"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class MediaTranscoder2Pass(BaseTranscoder):
|
class MediaTranscoder2Pass(BaseTranscoder):
|
||||||
def __init__(self, args):
|
def __init__(self, args):
|
||||||
super().__init__(args, VIDEO_DEFAULTS, AUDIO_DEFAULTS)
|
super().__init__(args, VIDEO_DEFAULTS, AUDIO_DEFAULTS)
|
||||||
@@ -59,7 +59,8 @@ class MediaTranscoder2Pass(BaseTranscoder):
|
|||||||
with open(self.log_path, "a", encoding="utf-8") as f:
|
with open(self.log_path, "a", encoding="utf-8") as f:
|
||||||
f.write(log_content)
|
f.write(log_content)
|
||||||
|
|
||||||
self._send_notification(encode_time=encode_time, new_info=new_info, vmaf=vmaf_score, full_text=log_content, extra_title="2-Pass转码")
|
self._send_notification(encode_time=encode_time, new_info=new_info, vmaf=vmaf_score,
|
||||||
|
full_text=log_content, extra_title="2-Pass转码")
|
||||||
|
|
||||||
print(f"\n转码完成!耗时: {encode_time:.2f} 秒")
|
print(f"\n转码完成!耗时: {encode_time:.2f} 秒")
|
||||||
print(f"输出文件: {self.output_path}")
|
print(f"输出文件: {self.output_path}")
|
||||||
@@ -111,6 +112,7 @@ class MediaTranscoder2Pass(BaseTranscoder):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"[Cleanup Warning] 无法删除临时日志 {log_file.name}: {e}")
|
print(f"[Cleanup Warning] 无法删除临时日志 {log_file.name}: {e}")
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description="2-Pass 可配置视频转码脚本")
|
parser = argparse.ArgumentParser(description="2-Pass 可配置视频转码脚本")
|
||||||
parser.add_argument("-i", "--input", required=True, help="输入视频文件")
|
parser.add_argument("-i", "--input", required=True, help="输入视频文件")
|
||||||
@@ -131,5 +133,6 @@ def main():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
sys.exit(f"发生错误: {e}")
|
sys.exit(f"发生错误: {e}")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
@@ -5,9 +5,10 @@ import time
|
|||||||
import subprocess
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from core import BaseTranscoder
|
||||||
|
|
||||||
# 将当前目录加入 path 以引入 core
|
# 将当前目录加入 path 以引入 core
|
||||||
sys.path.append(str(Path(__file__).resolve().parent))
|
sys.path.append(str(Path(__file__).resolve().parent))
|
||||||
from transcode_core import BaseTranscoder
|
|
||||||
|
|
||||||
VIDEO_DEFAULTS = {
|
VIDEO_DEFAULTS = {
|
||||||
"hevc_nvenc": ["-preset", "p7", "-tune", "uhq", "-rc", "vbr_hq", "-cq", "24", "-spatial-aq", "1", "-multipass", "2", "-pix_fmt", "p010le"],
|
"hevc_nvenc": ["-preset", "p7", "-tune", "uhq", "-rc", "vbr_hq", "-cq", "24", "-spatial-aq", "1", "-multipass", "2", "-pix_fmt", "p010le"],
|
||||||
@@ -22,6 +23,7 @@ AUDIO_DEFAULTS = {
|
|||||||
"opus": ["-c:a", "libopus", "-b:a", "128k", "-vbr", "on"],
|
"opus": ["-c:a", "libopus", "-b:a", "128k", "-vbr", "on"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class MediaTranscoder(BaseTranscoder):
|
class MediaTranscoder(BaseTranscoder):
|
||||||
def __init__(self, args):
|
def __init__(self, args):
|
||||||
super().__init__(args, VIDEO_DEFAULTS, AUDIO_DEFAULTS)
|
super().__init__(args, VIDEO_DEFAULTS, AUDIO_DEFAULTS)
|
||||||
@@ -59,7 +61,8 @@ class MediaTranscoder(BaseTranscoder):
|
|||||||
with open(self.log_path, "a", encoding="utf-8") as f:
|
with open(self.log_path, "a", encoding="utf-8") as f:
|
||||||
f.write(log_content)
|
f.write(log_content)
|
||||||
|
|
||||||
self._send_notification(encode_time=encode_time, new_info=new_info, vmaf=vmaf_score, full_text=log_content, extra_title="转码")
|
self._send_notification(encode_time=encode_time, new_info=new_info,
|
||||||
|
vmaf=vmaf_score, full_text=log_content, extra_title="转码")
|
||||||
|
|
||||||
print(f"\n转码完成!耗时: {encode_time:.2f} 秒")
|
print(f"\n转码完成!耗时: {encode_time:.2f} 秒")
|
||||||
print(f"输出文件: {self.output_path}")
|
print(f"输出文件: {self.output_path}")
|
||||||
@@ -94,6 +97,7 @@ class MediaTranscoder(BaseTranscoder):
|
|||||||
cmd.extend([str(self.output_path)])
|
cmd.extend([str(self.output_path)])
|
||||||
subprocess.run(cmd, check=True)
|
subprocess.run(cmd, check=True)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description="可配置视频转码脚本")
|
parser = argparse.ArgumentParser(description="可配置视频转码脚本")
|
||||||
parser.add_argument("-i", "--input", required=True, help="输入视频文件")
|
parser.add_argument("-i", "--input", required=True, help="输入视频文件")
|
||||||
@@ -113,5 +117,6 @@ def main():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
sys.exit(f"发生错误: {e}")
|
sys.exit(f"发生错误: {e}")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user