-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
examples(gstreamer): add new GStreamer examples
- Loading branch information
1 parent
4738879
commit fa7c941
Showing
4 changed files
with
158 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# | ||
# Copyright (c) 2024, Daily | ||
# | ||
# SPDX-License-Identifier: BSD 2-Clause License | ||
# | ||
|
||
import asyncio | ||
import aiohttp | ||
import argparse | ||
import sys | ||
|
||
from pipecat.pipeline.pipeline import Pipeline | ||
from pipecat.pipeline.runner import PipelineRunner | ||
from pipecat.pipeline.task import PipelineTask | ||
from pipecat.processors.gstreamer.pipeline_source import GStreamerPipelineSource | ||
from pipecat.transports.services.daily import DailyParams, DailyTransport | ||
|
||
from runner import configure_with_args | ||
|
||
from loguru import logger | ||
|
||
from dotenv import load_dotenv | ||
load_dotenv(override=True) | ||
|
||
logger.remove(0) | ||
logger.add(sys.stderr, level="DEBUG") | ||
|
||
|
||
async def main(): | ||
async with aiohttp.ClientSession() as session: | ||
parser = argparse.ArgumentParser(description="Daily AI SDK Bot Sample") | ||
parser.add_argument( | ||
"-i", | ||
"--input", | ||
type=str, | ||
required=True, | ||
help="Input video file") | ||
|
||
(room_url, _, args) = await configure_with_args(session, parser) | ||
|
||
transport = DailyTransport( | ||
room_url, | ||
None, | ||
"GStreamer", | ||
DailyParams( | ||
audio_out_enabled=True, | ||
audio_out_is_live=True, | ||
camera_out_enabled=True, | ||
camera_out_width=1280, | ||
camera_out_height=720, | ||
camera_out_is_live=True, | ||
) | ||
) | ||
|
||
gst = GStreamerPipelineSource( | ||
pipeline=f"filesrc location={args.input}", | ||
out_params=GStreamerPipelineSource.OutputParams( | ||
video_width=1280, | ||
video_height=720, | ||
audio_sample_rate=16000, | ||
audio_channels=1, | ||
) | ||
) | ||
|
||
pipeline = Pipeline([ | ||
gst, # GStreamer file source | ||
transport.output(), # Transport bot output | ||
]) | ||
|
||
task = PipelineTask(pipeline) | ||
|
||
runner = PipelineRunner() | ||
|
||
await runner.run(task) | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.run(main()) |
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,66 @@ | ||
# | ||
# Copyright (c) 2024, Daily | ||
# | ||
# SPDX-License-Identifier: BSD 2-Clause License | ||
# | ||
|
||
import asyncio | ||
import aiohttp | ||
import argparse | ||
import sys | ||
|
||
from pipecat.pipeline.pipeline import Pipeline | ||
from pipecat.pipeline.runner import PipelineRunner | ||
from pipecat.pipeline.task import PipelineTask | ||
from pipecat.processors.gstreamer.pipeline_source import GStreamerPipelineSource | ||
from pipecat.transports.services.daily import DailyParams, DailyTransport | ||
|
||
from runner import configure | ||
|
||
from loguru import logger | ||
|
||
from dotenv import load_dotenv | ||
load_dotenv(override=True) | ||
|
||
logger.remove(0) | ||
logger.add(sys.stderr, level="DEBUG") | ||
|
||
|
||
async def main(): | ||
async with aiohttp.ClientSession() as session: | ||
(room_url, _) = await configure(session) | ||
|
||
transport = DailyTransport( | ||
room_url, | ||
None, | ||
"GStreamer", | ||
DailyParams( | ||
camera_out_enabled=True, | ||
camera_out_width=1280, | ||
camera_out_height=720, | ||
camera_out_is_live=True, | ||
) | ||
) | ||
|
||
gst = GStreamerPipelineSource( | ||
pipeline="videotestsrc ! capsfilter caps=\"video/x-raw,width=1280,height=720\"", | ||
out_params=GStreamerPipelineSource.OutputParams( | ||
video_width=1280, | ||
video_height=720, | ||
) | ||
) | ||
|
||
pipeline = Pipeline([ | ||
gst, # GStreamer file source | ||
transport.output(), # Transport bot output | ||
]) | ||
|
||
task = PipelineTask(pipeline) | ||
|
||
runner = PipelineRunner() | ||
|
||
await runner.run(task) | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.run(main()) |
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