From a041bbc81bbcd3ca919ae76383d75ddbb0753beb Mon Sep 17 00:00:00 2001 From: flt6 <1404262047@qq.com> Date: Fri, 1 Aug 2025 22:11:16 +0800 Subject: [PATCH] VideoCompress --- VideoCompress/installer | 65 +++++++++++++++++++++++++++++++++++++++++ VideoCompress/main.py | 15 +++++----- 2 files changed, 73 insertions(+), 7 deletions(-) create mode 100644 VideoCompress/installer diff --git a/VideoCompress/installer b/VideoCompress/installer new file mode 100644 index 0000000..61f9209 --- /dev/null +++ b/VideoCompress/installer @@ -0,0 +1,65 @@ +; 脚本由 Inno Setup 脚本向导生成。 +; 有关创建 Inno Setup 脚本文件的详细信息,请参阅帮助文档! + +#define MyAppName "PDF解密" +#define MyAppVersion "1.1" +#define MyAppPublisher "flt" +#define MyAppURL "https://www.flt6.top/" + +[Setup] +; 注意:AppId 的值唯一标识此应用程序。不要在其他应用程序的安装程序中使用相同的 AppId 值。 +; (若要生成新的 GUID,请在 IDE 中单击 "工具|生成 GUID"。) +AppId={{34569C2B-A980-4031-94E1-7CC15988EA75} +AppName={#MyAppName} +AppVersion={#MyAppVersion} +;AppVerName={#MyAppName} {#MyAppVersion} +AppPublisher={#MyAppPublisher} +AppPublisherURL={#MyAppURL} +AppSupportURL={#MyAppURL} +AppUpdatesURL={#MyAppURL} +DefaultDirName={autopf}\pdfUnlock +DefaultGroupName={#MyAppName} +; 取消注释以下行以在非管理员安装模式下运行 (仅为当前用户安装)。 +;PrivilegesRequired=lowest +OutputBaseFilename=mysetup +SolidCompression=yes +WizardStyle=modern + +[Languages] +Name: "chinesesimp"; MessagesFile: "compiler:Default.isl" + +[Tasks] +Name: "pdfcontextmenu"; Description: "为PDF文件添加右键菜单"; GroupDescription: "上下文菜单:"; Flags: checkedonce +Name: "foldercontextmenu"; Description: "为文件夹添加右键菜单"; GroupDescription: "上下文菜单:"; Flags: checkedonce +Name: "folderbackgroundmenu"; Description: "为文件夹空白处添加右键菜单"; GroupDescription: "上下文菜单:"; Flags: checkedonce + +[Files] +Source: "C:\git\tools-3\pdf_unlock\dist\main\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs +; 注意:不要在任何共享系统文件上使用 "Flags: ignoreversion" + +[Registry] +; PDF文件右键菜单 +Root: HKCR; Subkey: "SystemFileAssociations\.pdf\shell\RemovePermissions"; ValueType: string; ValueName: ""; ValueData: "移除PDF权限"; Tasks: pdfcontextmenu; Flags: uninsdeletekey +Root: HKCR; Subkey: "SystemFileAssociations\.pdf\shell\RemovePermissions"; ValueType: string; ValueName: "MultiSelectModel"; ValueData: "Player"; Tasks: pdfcontextmenu +Root: HKCR; Subkey: "SystemFileAssociations\.pdf\shell\RemovePermissions\command"; ValueType: string; ValueName: ""; ValueData: """{app}\main.exe"" ""%1"""; Tasks: pdfcontextmenu + +; 文件夹右键菜单 +Root: HKCR; Subkey: "Directory\shell\RemovePermissions"; ValueType: string; ValueName: ""; ValueData: "移除PDF权限"; Tasks: foldercontextmenu; Flags: uninsdeletekey +Root: HKCR; Subkey: "Directory\shell\RemovePermissions\command"; ValueType: string; ValueName: ""; ValueData: """{app}\main.exe"" ""%1"""; Tasks: foldercontextmenu + +; 文件夹背景右键菜单 +Root: HKCR; Subkey: "Directory\Background\shell\RemovePermissions"; ValueType: string; ValueName: ""; ValueData: "移除PDF权限"; Tasks: folderbackgroundmenu; Flags: uninsdeletekey +Root: HKCR; Subkey: "Directory\Background\shell\RemovePermissions\command"; ValueType: string; ValueName: ""; ValueData: """{app}\main.exe"" ""%V"""; Tasks: folderbackgroundmenu + +[Icons] +Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}" + +[UninstallDelete] +Type: files; Name: "{app}\*" +Type: dirifempty; Name: "{app}" + +; [UninstallRun] +; 卸载时清理注册表项 +; Filename: "reg"; Parameters: "delete ""HKCR\SystemFileAssociations\.pdf\shell\RemovePermissions"" /f"; Flags: runhidden; RunOnceId: "DelPDFMenu" +; Filename: "reg"; Parameters: "delete ""HKCR\Directory\shell\RemovePermissions"" /f"; Flags: runhidden; RunOnceId: "DelFolderMenu" +; Filename: "reg"; Parameters: "delete ""HKCR\Directory\Background\shell\RemovePermissions"" /f"; Flags: runhidden; RunOnceId: "DelBgMenu" \ No newline at end of file diff --git a/VideoCompress/main.py b/VideoCompress/main.py index 9b9e596..8437ae1 100644 --- a/VideoCompress/main.py +++ b/VideoCompress/main.py @@ -177,7 +177,7 @@ def save_esti(): logging.warning("保存估算数据失败") logging.debug("error at save_esti",exc_info=e) -def fmt_time(t:int) -> str: +def fmt_time(t:float|int) -> str: if t>3600: return f"{t//3600}h {t//60}min {t%60}s" elif t>60: @@ -236,7 +236,8 @@ def process_video(video_path: Path, update_func=None): logging.warning(f"文件{output_file}存在,跳过") return use - command = get_cmd(str(video_path.absolute()),output_file) + video_path_str = str(video_path.absolute()) + command = get_cmd(video_path_str,output_file) try: result = subprocess.Popen( @@ -253,9 +254,9 @@ def process_video(video_path: Path, update_func=None): line+=result.stderr.read(1) # print(line[-1]) if 'warning' in line.lower(): - logging.warning(f"[FFmpeg]({video_path}): {line}") + logging.warning(f"[FFmpeg]({video_path_str}): {line}") elif 'error' in line.lower(): - logging.error(f"[FFmpeg]({video_path}): {line}") + logging.error(f"[FFmpeg]({video_path_str}): {line}") elif "frame=" in line: # print(line,end="") match = re.search(r"frame=\s*(\d+)",line) @@ -265,11 +266,11 @@ def process_video(video_path: Path, update_func=None): update_func(frame_number) if result.returncode != 0: - logging.error(f"处理文件 {video_path} 失败,返回码: {result.returncode},cmd={' '.join(command)}") + logging.error(f"处理文件 {video_path_str} 失败,返回码: {result.returncode},cmd={' '.join(command)}") logging.error(result.stdout) logging.error(result.stderr) else: - logging.debug(f"文件处理成功: {video_path} -> {output_file}") + logging.debug(f"文件处理成功: {video_path_str} -> {output_file}") end=time() if TRAIN: @@ -278,7 +279,7 @@ def process_video(video_path: Path, update_func=None): except Exception as e: - logging.error(f"执行 ffmpeg 命令时发生异常, 文件:{str(video_path)},cmd={' '.join(command)}",exc_info=e) + logging.error(f"执行 ffmpeg 命令时发生异常, 文件:{str(video_path_str)},cmd={' '.join(command)}",exc_info=e) return use def traverse_directory(root_dir: Path):