kukawka
Posts: 5
Joined: Tue Feb 06, 2018 11:12 am

Gstreamer and python

Tue Mar 27, 2018 6:58 am

Hello

Anybody know how to streaming video using gstreamer and picamera by python.

I have example to stream video from server rpi like this:

#!/usr/bin/env python

import gi
gi.require_version('Gst', '1.0')
gi.require_version('GstRtspServer', '1.0')
from gi.repository import Gst, GObject, GstRtspServer

GObject.threads_init()
Gst.init(None)

class RTSP_Server:
def __init__(self):
self.server = GstRtspServer.RTSPServer.new()
self.address = '192.168.1.13' #Pi local IP
self.port = '8554'
self.launch_description = '( rpicamsrc name=src bitrate=0 quantisation-parameter=24 intra-refresh-type=cyclic metering-mode=matrix annotation-mode=12 preview=false ! video/x-h264,profile=baseline,width=640,height=480,framerate=30/1 ! h264parse ! rtph264pay pt=96 name=pay0 )'

self.server.set_address(self.address)
self.server.set_service(self.port)
self.server.connect("client-connected", self.client_connected)
self.factory = GstRtspServer.RTSPMediaFactory.new()
self.factory.set_launch(self.launch_description)
self.factory.set_shared(True)
#self.factory.set_transport_mode(GstRtspServer.RTSPTransportMode.PLAY)
self.mount_points = self.server.get_mount_points()
self.mount_points.add_factory('/test', self.factory)

self.server.attach(None)
print('Stream ready')
GObject.MainLoop().run()

def client_connected(self, arg1, arg2):
print('Client connected')

server = RTSP_Server()


Example with videotestsrc is work, but with rpicamsrc doesn't want.
Anybody know solutions?

Return to “Python”

Who is online

Users browsing this forum: No registered users and 10 guests