diff --git a/docs/api.md b/docs/api.md index 2db6166..a18de08 100644 --- a/docs/api.md +++ b/docs/api.md @@ -37,6 +37,15 @@ This event is emitted just before `FFmpeg` is executed. |-------------|-------------|-----------------------------------------| | `arguments` | `list[str]` | A list of arguments to execute `FFmpeg` | +### `started` +This event is emitted just after `FFmpeg` is executed. + +**Parameters:** + +| Name | Type | Description | +|-------------|-------------|-----------------------------------------| +| `process` | `Popen` | The process object created right after starting `FFmpeg` | + ### `stderr` This event is emitted when a line is output to the standard error by `FFmpeg`. diff --git a/docs/examples/monitoring-status.md b/docs/examples/monitoring-status.md index 40cae62..ef3985b 100644 --- a/docs/examples/monitoring-status.md +++ b/docs/examples/monitoring-status.md @@ -28,6 +28,11 @@ In **python-ffmpeg**, the processing status of ffmpeg can be monitored through e def on_start(arguments: list[str]): print("arguments:", arguments) + @ffmpeg.on("started") + def on_started(process: subprocess.Popen): + print("process id: {process.pid}") + os.setpriority(os.PRIO_PROCESS, process.pid, 10) + @ffmpeg.on("stderr") def on_stderr(line): print("stderr:", line) @@ -80,6 +85,11 @@ In **python-ffmpeg**, the processing status of ffmpeg can be monitored through e def on_start(arguments: list[str]): print("arguments:", arguments) + @ffmpeg.on("started") + def on_started(process: subprocess.Popen): + print("process id: {process.pid}") + os.setpriority(os.PRIO_PROCESS, process.pid, 10) + @ffmpeg.on("stderr") def on_stderr(line): print("stderr:", line) diff --git a/ffmpeg/ffmpeg.py b/ffmpeg/ffmpeg.py index 36a8c73..f60cd6c 100644 --- a/ffmpeg/ffmpeg.py +++ b/ffmpeg/ffmpeg.py @@ -177,6 +177,8 @@ def execute(self, stream: Optional[Union[bytes, IO[bytes]]] = None, timeout: Opt stderr=subprocess.PIPE, ) + self.emit("started", self._process) + with concurrent.futures.ThreadPoolExecutor(max_workers=4) as executor: self._executed = True futures = [