fix: import path

This commit is contained in:
2026-03-18 23:10:35 +01:00
parent 6097317d25
commit 13f98a538d
2 changed files with 13 additions and 5 deletions
+6 -3
View File
@@ -5,8 +5,7 @@ import time
import subprocess
from pathlib import Path
sys.path.append(str(Path(__file__).resolve().parent))
from transcode_core import BaseTranscoder
from core import BaseTranscoder
VIDEO_DEFAULTS = {
"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"],
}
class MediaTranscoder2Pass(BaseTranscoder):
def __init__(self, args):
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:
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"输出文件: {self.output_path}")
@@ -111,6 +112,7 @@ class MediaTranscoder2Pass(BaseTranscoder):
except Exception as e:
print(f"[Cleanup Warning] 无法删除临时日志 {log_file.name}: {e}")
def main():
parser = argparse.ArgumentParser(description="2-Pass 可配置视频转码脚本")
parser.add_argument("-i", "--input", required=True, help="输入视频文件")
@@ -131,5 +133,6 @@ def main():
except Exception as e:
sys.exit(f"发生错误: {e}")
if __name__ == "__main__":
main()
+7 -2
View File
@@ -5,9 +5,10 @@ import time
import subprocess
from pathlib import Path
from core import BaseTranscoder
# 将当前目录加入 path 以引入 core
sys.path.append(str(Path(__file__).resolve().parent))
from transcode_core import BaseTranscoder
VIDEO_DEFAULTS = {
"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"],
}
class MediaTranscoder(BaseTranscoder):
def __init__(self, args):
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:
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"输出文件: {self.output_path}")
@@ -94,6 +97,7 @@ class MediaTranscoder(BaseTranscoder):
cmd.extend([str(self.output_path)])
subprocess.run(cmd, check=True)
def main():
parser = argparse.ArgumentParser(description="可配置视频转码脚本")
parser.add_argument("-i", "--input", required=True, help="输入视频文件")
@@ -113,5 +117,6 @@ def main():
except Exception as e:
sys.exit(f"发生错误: {e}")
if __name__ == "__main__":
main()