Skip to content

Commit

Permalink
processors(gstreamer): add clock_sync property
Browse files Browse the repository at this point in the history
  • Loading branch information
aconchillo committed Aug 5, 2024
1 parent fa7c941 commit 4133cd0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
6 changes: 2 additions & 4 deletions examples/foundational/18a-gstreamer-videotestsrc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import asyncio
import aiohttp
import argparse
import sys

from pipecat.pipeline.pipeline import Pipeline
Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions src/pipecat/processors/gstreamer/pipeline_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import asyncio

from openai import BaseModel
from pydantic import BaseModel

from pipecat.frames.frames import (
AudioRawFrame,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4133cd0

Please sign in to comment.