|
9 | 9 | import argparse |
10 | 10 | import threading |
11 | 11 | import tkinter as tk |
| 12 | +import tkinter.messagebox as messagebox |
12 | 13 | from collections import defaultdict |
13 | 14 | from .install_ffmpeg_if_needed import install_ffmpeg_if_needed |
14 | 15 | from colorama import init, Fore, Style |
@@ -596,6 +597,7 @@ def __init__(self, root, args): |
596 | 597 | self.args = args |
597 | 598 | self.stop_requested = False |
598 | 599 | self.running = False |
| 600 | + self.install_log = "" |
599 | 601 |
|
600 | 602 | frame = ttk.LabelFrame(root, text="Settings") |
601 | 603 | frame.pack(fill="x", padx=10, pady=10) |
@@ -659,6 +661,64 @@ def start_or_stop(self): |
659 | 661 | self._clear_tables() |
660 | 662 |
|
661 | 663 | def start_test(self): |
| 664 | + # 1. check FFmpeg is exists? |
| 665 | + if not shutil.which("ffmpeg"): |
| 666 | + self.prompt_install_ffmpeg() |
| 667 | + return |
| 668 | + |
| 669 | + # 2. run test flow |
| 670 | + self._execute_test_flow() |
| 671 | + |
| 672 | + def prompt_install_ffmpeg(self): |
| 673 | + title = "Missing Component: FFmpeg Not Found" |
| 674 | + msg = ( |
| 675 | + "The application requires the FFmpeg core component to access hardware acceleration, " |
| 676 | + "but it was not detected in your system PATH.\n\n" |
| 677 | + "Would you like to attempt an automatic download and configuration?\n" |
| 678 | + "(Supports Windows, Linux, and macOS)\n\n" |
| 679 | + "If you prefer to install it manually, please visit:\n" |
| 680 | + "https://ffmpeg.org/download.html" |
| 681 | + ) |
| 682 | + |
| 683 | + if messagebox.askyesno(title, msg): |
| 684 | + self.start_button.config(state="disabled") |
| 685 | + self.progress["mode"] = "indeterminate" |
| 686 | + self.progress.start() |
| 687 | + |
| 688 | + t = threading.Thread(target=self.run_install_thread, daemon=True) |
| 689 | + t.start() |
| 690 | + |
| 691 | + def run_install_thread(self): |
| 692 | + def update_ui_after_install(success): |
| 693 | + self.progress.stop() |
| 694 | + self.progress["mode"] = "determinate" |
| 695 | + self.start_button.config(state="normal") |
| 696 | + |
| 697 | + if success: |
| 698 | + messagebox.showinfo( |
| 699 | + "Installation Complete", |
| 700 | + "FFmpeg environment is now ready! You can click 'Start Test' to detect hardware codec performance." |
| 701 | + ) |
| 702 | + else: |
| 703 | + messagebox.showerror( |
| 704 | + "Auto-Installation Failed", |
| 705 | + "We were unable to complete the automatic installation. This is usually caused by network timeouts or insufficient permissions.\n\n" |
| 706 | + "Suggested steps:\n" |
| 707 | + "1. Download FFmpeg manually from: https://ffmpeg.org/download.html\n" |
| 708 | + "2. Extract and add the 'bin' folder to your system environment variable (PATH)." |
| 709 | + ) |
| 710 | + |
| 711 | + try: |
| 712 | + result = install_ffmpeg_if_needed() |
| 713 | + if result == 0 and shutil.which("ffmpeg"): |
| 714 | + self.root.after(0, lambda: update_ui_after_install(True)) |
| 715 | + else: |
| 716 | + self.root.after(0, lambda: update_ui_after_install(False)) |
| 717 | + except Exception as e: |
| 718 | + print(f"Installation error: {e}") |
| 719 | + self.root.after(0, lambda: update_ui_after_install(False)) |
| 720 | + |
| 721 | + def _execute_test_flow(self): |
662 | 722 | enc = self._safe_count(self.encoder_var, default=self.args.encoder_count) |
663 | 723 | dec = self._safe_count(self.decoder_var, default=self.args.decoder_count) |
664 | 724 | self.args.encoder_count = enc |
|
0 commit comments