-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from yukihiko-shinoda/hotfix-readme-example
Hotfix readme example
- Loading branch information
Showing
4 changed files
with
87 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import asyncio | ||
|
||
import ffmpeg | ||
|
||
# Reason: Following export method in __init__.py from Effective Python 2nd Edition item 85 | ||
from asynccpu import ProcessTaskPoolExecutor # type: ignore | ||
|
||
# Reason: Following export method in __init__.py from Effective Python 2nd Edition item 85 | ||
from asyncffmpeg import FFmpegCoroutineFactory, StreamSpec # type: ignore | ||
|
||
|
||
async def create_stream_spec_copy() -> StreamSpec: | ||
stream = ffmpeg.input("input.mp4") | ||
return ffmpeg.output(stream, "output1.mp4", c="copy") | ||
|
||
|
||
async def create_stream_spec_filter() -> StreamSpec: | ||
stream = ffmpeg.input("input.mp4") | ||
stream = ffmpeg.filter(stream, "scale", 768, -1) | ||
return ffmpeg.output(stream, "output2.mp4") | ||
|
||
|
||
async def main() -> None: | ||
ffmpeg_coroutine = FFmpegCoroutineFactory.create() | ||
|
||
with ProcessTaskPoolExecutor(max_workers=3, cancel_tasks_when_shutdown=True) as executor: | ||
awaitables = ( | ||
executor.create_process_task(ffmpeg_coroutine.execute, create_stream_spec) | ||
for create_stream_spec in [create_stream_spec_copy, create_stream_spec_filter] | ||
) | ||
await asyncio.gather(*awaitables) | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.run(main()) |