RidgeRun / gstd-1.x

GStreamer Daemon is a GStreamer framework for controlling audio and video streaming using TCP messages. This version is based on GStreamer 1.x
https://developer.ridgerun.com/wiki/index.php?title=Gstd-1.0
GNU Lesser General Public License v2.1
169 stars 54 forks source link

Append real-time RGB frames from appsink to a Python list #211

Open Fizmath opened 4 years ago

Fizmath commented 4 years ago

Hello

From your example the below code works and i get the rtsp video display for camera1 via autovideosink :

from pygstc.gstc import *
from pygstc.logger import *

gstd_logger = CustomLogger('pygstc_example', loglevel='INFO')

class PipelineEntity():
    def __init__(self, client, name, description):
        self._name = name
        self._description = description
        self._client = client
        print("Creating pipeline: " + self._name)
        self._client.pipeline_create(self._name, self._description)
    def play(self):
        print("Playing pipeline: " + self._name)
        self._client.pipeline_play(self._name)
    def stop(self):
        print("Stopping pipeline: " + self._name)
        self._client.pipeline_stop(self._name)
    def delete(self):
        print("Deleting pipeline: " + self._name)
        self._client.pipeline_delete(self._name)
    def eos(self):
        print("Sending EOS to pipeline: " + self._name)
        self._client.event_eos(self._name)
    def set_file_location(self, location):
        print("Setting " + self._name + " pipeline recording/snapshot location to " + location);
        filesink_name = "filesink_" + self._name;
        self._client.element_set(self._name, filesink_name, 'location', location);
    def listen_to(self, sink):
        print(self._name + " pipeline listening to " + sink);

        self._client.element_set(self._name, self._name + '_src', 'listen-to', sink);

pipelines_base = []

# Create GstD Python client
client = GstdClient(logger=gstd_logger)

# Create camera pipelines
camera0 = PipelineEntity(client, 'camera0', 'rtspsrc location=rtsp://{1..}.  latency=100 ! rtph264depay ! h264parse ! avdec_h264  ! videoscale ! video/x-raw,width=1280,height=720 ! appsink emit-signals=True')
camera1 = PipelineEntity(client, 'camera1', 'rtspsrc location=rtsp://{2..}   latency=100 ! rtph264depay ! h264parse ! avdec_h264 !  videoscale ! video/x-raw,width=1280,height=720 ! autovideosink')

pipelines_base.append(camera0)
pipelines_base.append(camera1)

# Play base pipelines
for pipeline in pipelines_base:
    pipeline.play()

for camera camera0 i want to get frames as output and one after the other append them to a python list for further Computer Vision processing . You see that i put appsink emit-signals=True in the end .Here is an example which uses appsink.connect("new-sample", on_buffer, None) :

http://lifestyletransfer.com/how-to-use-gstreamer-appsink-in-python/

would you please guide how to do that in gstd ?

thanks

michaelgruner commented 4 years ago

Hi @Fizmath, unfortunately you won't be able to get samples from the appsink using GStreamer Demon. The reason for this is that Gstd and your client are independent processes so the pointers in the former are not valid in the later (and viceversa).

For this you'll need to code your app using plain GStreamer API.