RTP Client doenst make connection when called from Python code

Aschwin Brandt aschwin.brandt at gmail.com
Tue Jun 2 11:36:36 UTC 2020


Hi all,

First of al, excuse me for the possible duplicate. I had some problems with
my subscription to this mailing list.

I've been working on a project where a client receives a stream over RTP
with the help of RTCP using the element RTPbin and udpsrc and udpsink. When
I run the following command from the command line it always works:

# Server
IP=127.0.0.1

gst-launch-1.0 rtpbin name=rtpbin \
filesrc location="" ! \
    rawvideoparse format=i420 width=3840 height=720 framerate=30/1 !
videoconvert !  x264enc ! \
    rtph264pay ! rtpbin.send_rtp_sink_0 \
    rtpbin.send_rtp_src_0 ! udpsink port=5004 host=$IP sync=true async=false
\
    rtpbin.send_rtcp_src_0 ! udpsink port=5006 host=$IP sync=true
async=false udpsrc port=5008 ! rtpbin.recv_rtcp_sink_0

# Client
gst-launch-1.0 -v rtpbin name=rtpbin \
udpsrc
caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=H264"
port=5004 ! \
rtpbin.recv_rtp_sink_0 rtpbin. ! rtph264depay ! h264parse ! avdec_h264 !
xvimagesink \
udpsrc port=5006 ! rtpbin.recv_rtcp_sink_0 rtpbin.send_rtcp_src_0 ! \
udpsink port=5008 async=false


But creating the exact same pipeline in Python for GStreamer makes it that
it sometimes connect and sometimes doesn't:

self.src_frame = Gst.ElementFactory.make('appsrc',  'appsrc2')
rtpbin = Gst.ElementFactory.make('rtpbin', 'rtpbin')

if self.stream_from_file == True:
    filesrc = Gst.ElementFactory.make("filesrc", "filesrc")
    filesrc.set_property("location", "")

rawvideoparse2 = Gst.ElementFactory.make('rawvideoparse', 'rawvideoparse2')
videoconvert2 = Gst.ElementFactory.make('videoconvert', 'videoconvert2')
x264enc2 = Gst.ElementFactory.make('x264enc', 'x264enc2')
rtph265pay2 = Gst.ElementFactory.make('rtph264pay', 'rtph265pay2')
udpsink_5004_2 = Gst.ElementFactory.make('udpsink', 'udpsink_5004_2')
udpsink_5006_2 = Gst.ElementFactory.make('udpsink', 'udpsink_5006_2')
udpsrc2 = Gst.ElementFactory.make('udpsrc',  'udpsrc2')

# Add to pipeline
pipeline = Gst.Pipeline()
pipeline.add(rtpbin)

if self.stream_from_file:
    pipeline.add(filesrc)
else:
    pipeline.add(self.src_frame)

pipeline.add(rawvideoparse2)
pipeline.add(videoconvert2)
pipeline.add(x264enc2)
pipeline.add(rtph265pay2)
pipeline.add(udpsink_5004_2)
pipeline.add(udpsink_5006_2)
pipeline.add(udpsrc2)

# Linking
if self.stream_from_file:
    filesrc.link(rawvideoparse2)
else:
    self.src_frame.link(rawvideoparse2)

rawvideoparse2.link(videoconvert2)
videoconvert2.link(x264enc2)
x264enc2.link(rtph265pay2)
# caps2.link(rtph265pay2)

rtph265pay2.link_pads('src', rtpbin, 'send_rtp_sink_0')
rtpbin.link_pads('send_rtp_src_0', udpsink_5004_2 , None)
rtpbin.link_pads('send_rtcp_src_0',  udpsink_5006_2,  None)

udpsrc2.link_pads('src',  rtpbin,  'recv_rtcp_sink_0')

# Set Properties
rawvideoparse2.set_property('format', 'i420')
rawvideoparse2.set_property('width' , self.width)
rawvideoparse2.set_property('height', self.height)
rawvideoparse2.framerate = self.framerate

udpsrc2.set_property('port', 5004)

# Create probe
if self.stream_from_file == True:
    pad = filesrc.get_static_pad("src")
else:
    pad = self.src_frame.get_static_pad("src")

udpsink_5004_2.set_property('port',  5004)
udpsink_5004_2.set_property('host',  self.rec_ip_addr)

udpsink_5004_2.set_property('async', False)
udpsink_5004_2.set_property('sync', True)

udpsink_5006_2.set_property('port',  5006)
udpsink_5006_2.set_property('host',  self.rec_ip_addr)

udpsink_5006_2.set_property('async', False)
udpsink_5006_2.set_property('sync', True)

self.pipeline = pipeline

I've tried different content, ports, using a different IP (instead of
127.0.0.1), checked the difference between pipelines from commandline and
the python code using the DOT files, changed encoder settings to only
transmit i-frames, changed preset of the encoder to 1 (I thought it could be
the speed of the encoder since I'm using an big resolution. GST_DEBUG=3
doesn't give errors on client or server side and it does receive an RTCP
session because I do get messages in the console. The only thing I havent
tried is doing it on two PC's because I currently don't have them available.

I must be missing something. Please help!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20200602/edcf4d59/attachment-0001.htm>


More information about the gstreamer-devel mailing list