Executes a subprocess command and handles logging and errors. Args: cmd: The command to execute as a list of strings. process_name: A descriptive name for the process (e.g., "Encoding").
(self, cmd: List[str], process_name: str)
| 97 | logging.warning(f"Decoder may not be executable: {self.decoder_path}") |
| 98 | |
| 99 | def _run_command(self, cmd: List[str], process_name: str): |
| 100 | """ |
| 101 | Executes a subprocess command and handles logging and errors. |
| 102 | |
| 103 | Args: |
| 104 | cmd: The command to execute as a list of strings. |
| 105 | process_name: A descriptive name for the process (e.g., "Encoding"). |
| 106 | """ |
| 107 | logging.info(f"{process_name} with {self.video_codec_type.upper()}...") |
| 108 | logging.debug(f"Executing command: {shlex.join(cmd)}") |
| 109 | |
| 110 | try: |
| 111 | result = subprocess.run(cmd, check=True, capture_output=True, text=True, encoding='utf-8') |
| 112 | logging.debug(f"Process stdout: {result.stdout}") |
| 113 | if result.stderr: |
| 114 | logging.warning(f"Process stderr: {result.stderr}") |
| 115 | logging.info(f"{process_name} completed successfully.") |
| 116 | return result |
| 117 | except subprocess.CalledProcessError as e: |
| 118 | logging.error(f"{process_name} failed.") |
| 119 | logging.error(f"Return code: {e.returncode}") |
| 120 | logging.error(f"Command: {shlex.join(e.cmd)}") |
| 121 | logging.error(f"Stderr: {e.stderr}") |
| 122 | logging.error(f"Stdout: {e.stdout}") |
| 123 | raise |
| 124 | |
| 125 | # --- Command Builders: Encoder --- |
| 126 |