Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add started event directly after process is started. #66

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
10 changes: 10 additions & 0 deletions docs/examples/monitoring-status.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions ffmpeg/ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down