{"id":78,"date":"2024-12-28T21:05:20","date_gmt":"2024-12-28T13:05:20","guid":{"rendered":"https:\/\/taupis.com\/?p=78"},"modified":"2026-08-06T21:30:00","modified_gmt":"2026-08-06T13:30:00","slug":"78","status":"publish","type":"post","link":"https:\/\/taupis.com\/?p=78","title":{"rendered":"\u97f3\u89c6\u9891\u8f6c\u6362\u8f6f\u4ef6"},"content":{"rendered":"<div class=\"single-content\">\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-92\" src=\"https:\/\/taupis.com\/wp-content\/uploads\/2024\/12\/20260806131710314959-164x300.webp\" alt=\"\u97f3\u89c6\u9891\u8f6c\u6362\u8f6f\u4ef6\" width=\"164\" height=\"300\" srcset=\"https:\/\/taupis.com\/wp-content\/uploads\/2024\/12\/20260806131710314959-164x300.webp 164w, https:\/\/taupis.com\/wp-content\/uploads\/2024\/12\/20260806131710314959-560x1024.webp 560w, https:\/\/taupis.com\/wp-content\/uploads\/2024\/12\/20260806131710314959.webp 598w\" sizes=\"auto, (max-width: 164px) 100vw, 164px\" \/><\/p>\n<p><strong><mark data-color=\"#111827\">\u66f4\u65b0\u65e5\u5fd712.30<\/mark><\/strong><\/p>\n<p>\u63d2\u4ef6\u6539\u4e3a\u81ea\u52a8\u68c0\u6d4b\uff0c\u68c0\u67e5\u4e0d\u5230\u7684\u8bdd\u4f1a\u81ea\u52a8\u4e0b\u8f7d\u5b89\u88c5<\/p>\n<p>\u65b0\u589e\u6279\u91cf\u5904\u7406\u89c6\u9891\u4ee5\u53ca\u97f3\u9891<\/p>\n<p>\u65b0\u589e\u81ea\u7531\u52fe\u9009\u591a\u7ebf\u7a0b\u5904\u7406\u4efb\u52a1<\/p>\n<p>\u5c31\u8fd9\u4e48\u591a\u6ca1\u6709\u5176\u4ed6\u7684\uff0c\u540e\u7eed\u66f4\u65b0\u770b\u4e2a\u4eba\u60c5\u51b5\uff01\uff01\uff01<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u4ee5\u4e0b\u662f\u6e90\u7801<\/p>\n<pre><code>import tkinter as tk\r\nfrom tkinter import filedialog, messagebox\r\nimport subprocess\r\nimport os\r\nimport requests\r\nimport zipfile\r\nimport threading\r\n\r\n# \u5b9a\u4e49\u6267\u884c\u8017\u65f6\u64cd\u4f5c\u7684\u51fd\u6570\r\ndef run_task_in_thread(task):\r\n    threading.Thread(target=task).start()\r\n\r\n# \u5b9a\u4e49\u6267\u884c\u6279\u5904\u7406\u811a\u672c\u7684\u51fd\u6570\r\ndef run_batch_script():\r\n    ffmpeg_url = \"http:\/\/valkire.cn\/down.php\/f4f0acdca149b604a2a9d76b4e2a4ac6.zip\"  # FFmpeg\u4e0b\u8f7d\u94fe\u63a5\r\n    ffmpeg_path = r\"C:\\ffmpeg\\bin\"\r\n    ffmpeg_zip = r\"C:\\ffmpeg.zip\"\r\n\r\n    # \u68c0\u6d4bFFmpeg\u662f\u5426\u5df2\u5b89\u88c5\r\n    def is_ffmpeg_installed():\r\n        return os.path.exists(ffmpeg_path)\r\n\r\n    # \u4e0b\u8f7dFFmpeg\r\n    def download_ffmpeg(url, zip_path):\r\n        response = requests.get(url, stream=True)  # \u4f7f\u7528stream=True\u6765\u9010\u5757\u4e0b\u8f7d\r\n        total_size = int(response.headers.get('content-length', 0))\r\n        block_size = 1024  # 1 Kibibyte\r\n        wrote = 0\r\n        with open(zip_path, 'wb') as f:\r\n            for data in response.iter_content(block_size):\r\n                wrote += len(data)\r\n                f.write(data)\r\n                # \u66f4\u65b0\u65e5\u5fd7\u4e2d\u7684\u8fdb\u5ea6\u6761\r\n                progress = (wrote \/ total_size) * 100\r\n                log_message(f\"\u8fd9\u662f\u4e0b\u8f7d\u5fc5\u8981\u63d2\u4ef6\uff0c\u4e0b\u8f7d\u8fc7\u7a0b\u6709\u70b9\u6162\uff0c\u8bf7\u8010\u5fc3\u7b49\u5f85\uff0c\u603b\u5171\u5927\u5c0f383MB \/n \u4e0b\u8f7d\u8fdb\u5ea6: {progress:.2f}%\")\r\n        print(\"\u4e0b\u8f7d\u5b8c\u6210\u3002\")  # \u6700\u540e\u6253\u5370\u5b8c\u6210\u4fe1\u606f\r\n\r\n    # \u89e3\u538bFFmpeg\r\n    def unzip_ffmpeg(zip_path, extract_path):\r\n        with zipfile.ZipFile(zip_path, 'r') as zip_ref:\r\n            zip_ref.extractall(extract_path)\r\n        log_message(\"FFmpeg\u89e3\u538b\u5b8c\u6210\u3002\")\r\n\r\n    # \u6dfb\u52a0\u5230\u7cfb\u7edfPATH\r\n    def add_to_path(path):\r\n        current_path = os.environ['PATH']\r\n        if path not in current_path:\r\n            os.environ[\"PATH\"] += os.pathsep + path\r\n            subprocess.run([\"setx\", \"PATH\", f\"{current_path};{path}\"], shell=True)\r\n            log_message(f\"{path}\u5df2\u6dfb\u52a0\u5230\u7cfb\u7edfPATH\u3002\")\r\n        else:\r\n            log_message(f\"{path}\u5df2\u5728\u7cfb\u7edfPATH\u4e2d\u3002\")\r\n\r\n    if not is_ffmpeg_installed():\r\n        log_message(\"FFmpeg\u672a\u68c0\u6d4b\u5230\uff0c\u5f00\u59cb\u4e0b\u8f7d...\")\r\n        download_ffmpeg(ffmpeg_url, ffmpeg_zip)\r\n        log_message(\"FFmpeg\u4e0b\u8f7d\u5b8c\u6210\uff0c\u5f00\u59cb\u89e3\u538b...\")\r\n        unzip_ffmpeg(ffmpeg_zip, r\"C:\\ffmpeg\")\r\n        log_message(\"FFmpeg\u89e3\u538b\u5b8c\u6210\uff0c\u68c0\u67e5\u662f\u5426\u5df2\u6dfb\u52a0\u5230\u7cfb\u7edfPATH...\")\r\n        add_to_path(ffmpeg_path)\r\n        log_message(\"FFmpeg\u5b89\u88c5\u5b8c\u6210\uff0c\u53ef\u4ee5\u7ee7\u7eed\u64cd\u4f5c\uff01\")\r\n    else:\r\n        log_message(\"\u68c0\u67e5\u5230\u63d2\u4ef6FFmpeg\u5df2\u5b89\u88c5\uff0c\u65e0\u9700\u91cd\u590d\u5b89\u88c5\u3002\")\r\n\r\n# \u5b9a\u4e49\u6267\u884c\u5355\u4e2a\u97f3\u9891\u5904\u7406\u7684\u51fd\u6570\r\ndef change_mp3_quality():\r\n    input_file = filedialog.askopenfilename(title=\"\u9009\u62e9MP3\u6587\u4ef6\", filetypes=[(\"MP3 files\", \"*.mp3\")])\r\n    if not input_file:\r\n        return\r\n    output_file = filedialog.asksaveasfilename(title=\"\u4fdd\u5b58\u97f3\u9891\u6587\u4ef6\", defaultextension=\".mp3\", filetypes=[(\"MP3 files\", \"*.mp3\"), (\"FLAC files\", \"*.flac\")])\r\n    if not output_file:\r\n        return\r\n    bitrate = bitrate_var.get()\r\n    if bitrate == \"\u65e0\u635f\":\r\n        output_file = os.path.splitext(output_file)[0] + '.flac'\r\n        command = f'ffmpeg -i \"{input_file}\" -c:a flac -b:a 1411k \"{output_file}\"'\r\n    else:\r\n        output_file = os.path.splitext(output_file)[0] + '.mp3' if not output_file.lower().endswith('.mp3') else output_file\r\n        command = f'ffmpeg -i \"{input_file}\" -b:a {bitrate} \"{output_file}\"'\r\n    if use_thread_var.get():\r\n        run_task_in_thread(lambda: subprocess.run(command, shell=True))\r\n    else:\r\n        subprocess.run(command, shell=True)\r\n    log_message(\"\u97f3\u9891\u5904\u7406\u5b8c\u6210\")\r\n\r\n# \u5b9a\u4e49\u6267\u884c\u5355\u4e2a\u89c6\u9891\u683c\u5f0f\u8f6c\u6362\u7684\u51fd\u6570\r\ndef convert_video_format():\r\n    input_file = filedialog.askopenfilename(title=\"\u9009\u62e9\u89c6\u9891\u6587\u4ef6\", filetypes=[(\"Video files\", \"*.*\")])\r\n    if not input_file:\r\n        return\r\n    output_file = filedialog.asksaveasfilename(title=\"\u4fdd\u5b58\u89c6\u9891\u6587\u4ef6\", defaultextension=\".mp4\", filetypes=[(\"MP4 files\", \"*.mp4\"), (\"AVI files\", \"*.avi\"), (\"MOV files\", \"*.mov\")])\r\n    if not output_file:\r\n        return\r\n    format = format_var.get()\r\n    output_file = os.path.splitext(output_file)[0] + '.' + format if not output_file.lower().endswith('.' + format) else output_file\r\n    command = f'ffmpeg -i \"{input_file}\" -codec:v libx264 -codec:a aac -crf 23 -preset fast \"{output_file}\"'\r\n    if use_thread_var.get():\r\n        run_task_in_thread(lambda: subprocess.run(command, shell=True))\r\n    else:\r\n        subprocess.run(command, shell=True)\r\n    log_message(\"\u89c6\u9891\u683c\u5f0f\u8f6c\u6362\u5b8c\u6210\")\r\n\r\n# \u5b9a\u4e49\u6267\u884c\u97f3\u9891\u6279\u91cf\u5904\u7406\u7684\u51fd\u6570\r\ndef batch_process_audio():\r\n    file_paths = filedialog.askopenfilenames(title=\"\u9009\u62e9\u97f3\u9891\u6587\u4ef6\", filetypes=[(\"Audio files\", \"*.mp3 *.wav *.flac\")])\r\n    if not file_paths:\r\n        return\r\n    for file_path in file_paths:\r\n        process_audio_file(file_path)\r\n\r\n# \u5b9a\u4e49\u6267\u884c\u89c6\u9891\u6279\u91cf\u5904\u7406\u7684\u51fd\u6570\r\ndef batch_process_video():\r\n    file_paths = filedialog.askopenfilenames(title=\"\u9009\u62e9\u89c6\u9891\u6587\u4ef6\", filetypes=[(\"Video files\", \"*.mp4 *.avi *.mov\")])\r\n    if not file_paths:\r\n        return\r\n    for file_path in file_paths:\r\n        process_video_file(file_path)\r\n\r\n# \u5b9a\u4e49\u5904\u7406\u5355\u4e2a\u97f3\u9891\u6587\u4ef6\u7684\u51fd\u6570\r\ndef process_audio_file(file_path):\r\n    output_file = os.path.splitext(file_path)[0] + '_processed.mp3'\r\n    bitrate = bitrate_var.get()\r\n    command = f'ffmpeg -i \"{file_path}\" -b:a {bitrate} \"{output_file}\"'\r\n    if use_thread_var.get():\r\n        run_task_in_thread(lambda: subprocess.run(command, shell=True))\r\n    else:\r\n        subprocess.run(command, shell=True)\r\n    log_message(f\"\u97f3\u9891\u6587\u4ef6 {os.path.basename(file_path)} \u5904\u7406\u5b8c\u6210\uff0c\u4fdd\u5b58\u4e3a {os.path.basename(output_file)}\")\r\n\r\n# \u5b9a\u4e49\u5904\u7406\u5355\u4e2a\u89c6\u9891\u6587\u4ef6\u7684\u51fd\u6570\r\ndef process_video_file(file_path):\r\n    output_file = os.path.splitext(file_path)[0] + '_processed.mp4'\r\n    format = format_var.get()\r\n    command = f'ffmpeg -i \"{file_path}\" -codec:v libx264 -codec:a aac -crf 23 -preset fast \"{output_file}\"'\r\n    if use_thread_var.get():\r\n        run_task_in_thread(lambda: subprocess.run(command, shell=True))\r\n    else:\r\n        subprocess.run(command, shell=True)\r\n    log_message(f\"\u89c6\u9891\u6587\u4ef6 {os.path.basename(file_path)} \u683c\u5f0f\u8f6c\u6362\u5b8c\u6210\uff0c\u4fdd\u5b58\u4e3a {os.path.basename(output_file)}\")\r\n\r\n# \u5b9a\u4e49\u66f4\u65b0\u65e5\u5fd7\u7684\u51fd\u6570\r\ndef log_message(message):\r\n    log_text.insert(tk.END, message + \"\\n\")\r\n    log_text.see(tk.END)  # \u81ea\u52a8\u6eda\u52a8\u5230\u6700\u65b0\u65e5\u5fd7\r\n\r\n# \u521b\u5efa\u4e3b\u7a97\u53e3\r\nroot = tk.Tk()\r\nroot.title(\"\u97f3\u89c6\u9891\u5904\u7406\u5de5\u5177\")\r\nroot.geometry(\"400x700\")  # \u8bbe\u7f6e\u7a97\u53e3\u5927\u5c0f\u4e3a400x600\r\nroot.iconbitmap(r\"c:\\Users\\Administrator\\Desktop\\stool.ico\")\r\n# \u521b\u5efa\u65e5\u5fd7\u8f93\u51fa\u6846\r\nlog_text = tk.Text(root, height=10, width=50)\r\nlog_text.pack(pady=10)\r\n\r\n# \u521b\u5efa\u7ebf\u7a0b\u5904\u7406\u9009\u9879\r\ntk.Label(root, text=\"\u662f\u5426\u4f7f\u7528\u7ebf\u7a0b\u5904\u7406\u4efb\u52a1\uff1f\u7ebf\u7a0b\u5904\u7406\u4f1a\u66f4\u5feb\u54e6\uff01\").pack()\r\nuse_thread_var = tk.BooleanVar()\r\ntk.Checkbutton(root, text=\"\u4f7f\u7528\u7ebf\u7a0b\", variable=use_thread_var).pack()\r\n\r\n# \u68c0\u6d4b\u5e76\u5b89\u88c5FFmpeg\r\nrun_task_in_thread(run_batch_script)\r\n\r\n# \u521b\u5efaMP3\u97f3\u8d28\u4fee\u6539\u90e8\u5206\u7684GUI\r\ntk.Label(root, text=\"MP3\u97f3\u8d28\u4fee\u6539\").pack()\r\nbitrate_var = tk.StringVar(value=\"128k\")\r\ntk.Label(root, text=\"\u9009\u62e9\u6bd4\u7279\u7387:\").pack()\r\ntk.Radiobutton(root, text=\"98k\", variable=bitrate_var, value=\"98k\").pack()\r\ntk.Radiobutton(root, text=\"128k\", variable=bitrate_var, value=\"128k\").pack()\r\ntk.Radiobutton(root, text=\"256k\", variable=bitrate_var, value=\"256k\").pack()\r\ntk.Radiobutton(root, text=\"320k\", variable=bitrate_var, value=\"320k\").pack()\r\ntk.Radiobutton(root, text=\"\u65e0\u635f (1411kbps)\", variable=bitrate_var, value=\"\u65e0\u635f\").pack()\r\ntk.Button(root, text=\"\u4fee\u6539MP3\u97f3\u8d28\", command=change_mp3_quality).pack()\r\n#\u521b\u5efa\u97f3\u9891\u6279\u91cf\u5904\u7406\u90e8\u5206\u7684GUI\r\ntk.Label(root, text=\"\u97f3\u9891\u6279\u91cf\u5904\u7406\").pack()\r\ntk.Button(root, text=\"\u6279\u91cf\u5904\u7406\u97f3\u9891\", command=batch_process_audio).pack()\r\n\r\n# \u521b\u5efa\u89c6\u9891\u683c\u5f0f\u8f6c\u6362\u90e8\u5206\u7684GUI\r\ntk.Label(root, text=\"\u89c6\u9891\u683c\u5f0f\u8f6c\u6362\").pack()\r\nformat_var = tk.StringVar(value=\"mp4\")\r\ntk.Label(root, text=\"\u9009\u62e9\u683c\u5f0f:\").pack()\r\ntk.Radiobutton(root, text=\"MP4\", variable=format_var, value=\"mp4\").pack()\r\ntk.Radiobutton(root, text=\"AVI\", variable=format_var, value=\"avi\").pack()\r\ntk.Radiobutton(root, text=\"MOV\", variable=format_var, value=\"mov\").pack()\r\ntk.Button(root, text=\"\u8f6c\u6362\u89c6\u9891\u683c\u5f0f\", command=convert_video_format).pack()\r\n\r\n\r\n\r\n#\u521b\u5efa\u89c6\u9891\u6279\u91cf\u5904\u7406\u90e8\u5206\u7684GUI\r\ntk.Label(root, text=\"\u89c6\u9891\u6279\u91cf\u5904\u7406\").pack()\r\ntk.Button(root, text=\"\u6279\u91cf\u5904\u7406\u89c6\u9891\", command=batch_process_video).pack()\r\n\r\n#\u8fd0\u884c\u4e3b\u5faa\u73af\r\nroot.mainloop()<\/code><\/pre>\n<p>&nbsp;<\/p>\n<\/div>\n<div class=\"single-footer\">\n<div class=\"single_footer_box\"><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u66f4\u65b0\u65e5\u5fd712.30 \u63d2\u4ef6\u6539\u4e3a\u81ea\u52a8\u68c0\u6d4b\uff0c\u68c0\u67e5\u4e0d\u5230\u7684\u8bdd\u4f1a\u81ea\u52a8\u4e0b\u8f7d\u5b89\u88c5 \u65b0\u589e\u6279\u91cf\u5904\u7406\u89c6\u9891\u4ee5\u53ca\u97f3\u9891 \u65b0\u589e\u81ea\u7531\u52fe\u9009\u591a\u7ebf\u7a0b [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":87,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[13],"class_list":["post-78","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-python"],"_links":{"self":[{"href":"https:\/\/taupis.com\/index.php?rest_route=\/wp\/v2\/posts\/78","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/taupis.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/taupis.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/taupis.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/taupis.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=78"}],"version-history":[{"count":3,"href":"https:\/\/taupis.com\/index.php?rest_route=\/wp\/v2\/posts\/78\/revisions"}],"predecessor-version":[{"id":93,"href":"https:\/\/taupis.com\/index.php?rest_route=\/wp\/v2\/posts\/78\/revisions\/93"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/taupis.com\/index.php?rest_route=\/wp\/v2\/media\/87"}],"wp:attachment":[{"href":"https:\/\/taupis.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=78"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/taupis.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=78"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/taupis.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=78"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}