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

Adding async_output when already running async the run call to asynci… #136

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rcolfin
Copy link

@rcolfin rcolfin commented Dec 13, 2024

…o.run will raise an exception.

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Fixed tickets fixes #issuenum
Related issues/PRs #issuenum
License MIT

What's in this PR?

Added a new function to _media.py called async_output

This new function internally calls the async_run instead of run. which can be awaited.

Why?

If already running within an asyncio event loop, the call under https://github.com/quasarstream/python-ffmpeg-video-streaming/blob/master/ffmpeg_streaming/_media.py#L119 will raise a RuntimeError: "asyncio.run() cannot be called from a running event loop"

A workaround for the client is to avoid the run_command when running stream.output as seen below:

    stream.output(output, run_command=False)
    await stream.async_run(ffmpeg_bin="ffmpeg")

Which problem does the PR fix?

Example Usage

await stream.async_output(output)
~~~

#### To Do

- [ ] Create tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant