From 4133cd03bba386ded3ff591c8b3ae366cc9f9853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Mon, 5 Aug 2024 09:20:44 -0700 Subject: [PATCH] processors(gstreamer): add clock_sync property --- examples/foundational/18a-gstreamer-videotestsrc.py | 6 ++---- src/pipecat/processors/gstreamer/pipeline_source.py | 7 ++++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/examples/foundational/18a-gstreamer-videotestsrc.py b/examples/foundational/18a-gstreamer-videotestsrc.py index a107fbd5d..7c71e06ce 100644 --- a/examples/foundational/18a-gstreamer-videotestsrc.py +++ b/examples/foundational/18a-gstreamer-videotestsrc.py @@ -6,7 +6,6 @@ import asyncio import aiohttp -import argparse import sys from pipecat.pipeline.pipeline import Pipeline @@ -43,12 +42,11 @@ async def main(): ) gst = GStreamerPipelineSource( - pipeline="videotestsrc ! capsfilter caps=\"video/x-raw,width=1280,height=720\"", + pipeline="videotestsrc ! capsfilter caps=\"video/x-raw,width=1280,height=720,framerate=30/1\"", out_params=GStreamerPipelineSource.OutputParams( video_width=1280, video_height=720, - ) - ) + clock_sync=False)) pipeline = Pipeline([ gst, # GStreamer file source diff --git a/src/pipecat/processors/gstreamer/pipeline_source.py b/src/pipecat/processors/gstreamer/pipeline_source.py index bc265dcde..89f7cd4d6 100644 --- a/src/pipecat/processors/gstreamer/pipeline_source.py +++ b/src/pipecat/processors/gstreamer/pipeline_source.py @@ -6,7 +6,7 @@ import asyncio -from openai import BaseModel +from pydantic import BaseModel from pipecat.frames.frames import ( AudioRawFrame, @@ -37,6 +37,7 @@ class OutputParams(BaseModel): video_height: int = 720 audio_sample_rate: int = 16000 audio_channels: int = 1 + clock_sync: bool = True def __init__(self, *, pipeline: str, out_params: OutputParams = OutputParams(), **kwargs): super().__init__(**kwargs) @@ -156,7 +157,7 @@ def _decodebin_audio(self, pad: Gst.Pad): audiocapsfilter.set_property("caps", audiocaps) appsink_audio = Gst.ElementFactory.make("appsink", None) appsink_audio.set_property("emit-signals", True) - appsink_audio.set_property("sync", False) + appsink_audio.set_property("sync", self._out_params.clock_sync) appsink_audio.connect("new-sample", self._appsink_audio_new_sample) self._player.add(queue_audio) @@ -189,7 +190,7 @@ def _decodebin_video(self, pad: Gst.Pad): appsink_video = Gst.ElementFactory.make("appsink", None) appsink_video.set_property("emit-signals", True) - appsink_video.set_property("sync", False) + appsink_video.set_property("sync", self._out_params.clock_sync) appsink_video.connect("new-sample", self._appsink_video_new_sample) self._player.add(queue_video)