RTSP server not working with .ts files

Section1: problem statement

I have a working deepstream application developed based on deepstream_test_5 in C that uses uri=file://../streamer/Vehicle.Target.Sample_EO.ts under [source0] tag in a config file.

It runs using this command:
./my-app -c configs/test_config_file_src_infer.txt

Desired next step
Now I want to configure the application to use uri=rtsp://127.0.0.1:8554/stream1 under the [source0] tag in the config file.

============================================================

Section2: Checking the video

nvidia@jetson2:/opt/nvidia/deepstream/deepstream/sources/apps/sample_apps/my-app/streamer$ gst-discoverer-1.0 Vehicle.Target.Sample_EO.ts

Analyzing file:///opt/nvidia/deepstream/deepstream/sources/apps/sample_apps/my-app/streamer/Vehicle.Target.Sample_EO.ts

Opening in BLOCKING MODE 

NvMMLiteOpen : Block : BlockType = 261 

NVMEDIA: Reading vendor.tegra.display-size : status: 6 

NvMMLiteBlockCreate : Block : BlockType = 261 

Done discovering file:///opt/nvidia/deepstream/deepstream/sources/apps/sample_apps/my-app/streamer/Vehicle.Target.Sample_EO.ts

Topology:
  container: MPEG-2 Transport Stream
	video: H.264 (Main Profile)

Properties:
  Duration: 0:00:28.445187777
  Seekable: yes
  Live: no
  Tags: 
	  video codec: H.264

============================================================

Section3: Set up of the RTSP server (look at comment by Dusan Kovacevic): https://stackoverflow.com/questions/59858898/how-to-convert-a-video-on-disk-to-a-rtsp-stream#

  • note the changes to my pipeline in the python file for src_demux and h264_transcode!

rtsp_server.py

import sys
import gi

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

loop = GLib.MainLoop()
Gst.init(None)


class TestRtspMediaFactory(GstRtspServer.RTSPMediaFactory):
	def __init__(self):
		GstRtspServer.RTSPMediaFactory.__init__(self)

	def do_create_element(self, url):
		#set mp4 file path to filesrc's location property
		src_demux = "filesrc location=streamer/Vehicle.Target.Sample_EO.ts ! qtdemux name=demux"

                    # Uncomment below to use a test source
                    # src_demux = "videotestsrc ! qtdemux name=demux"

		h264_transcode = "demux.video_0"
		#uncomment following line if video transcoding is necessary
		h264_transcode = "demux.video_0 ! decodebin ! queue ! x264enc"
		pipeline = "{0} {1} ! queue ! rtph264pay name=pay0 config-interval=1 pt=96".format(src_demux, h264_transcode)
		print("Element created: " + pipeline)
		return Gst.parse_launch(pipeline)


class GstreamerRtspServer:
	def __init__(self):
		self.rtspServer = GstRtspServer.RTSPServer()
		factory = TestRtspMediaFactory()
		factory.set_shared(True)
		mountPoints = self.rtspServer.get_mount_points()
		mountPoints.add_factory("/stream1", factory)
		self.rtspServer.attach(None)


if __name__ == '__main__':
	s = GstreamerRtspServer()
	loop.run()

running the server (rtsp_server.py):
python3 rtsp_server.py

  • please note src_demux can be changed to use a videotestsrc and it works for step 3!

============================================================

Section 4: reading from the RTSP stream with Gstreamer

  • run gstreamer

      nvidia@jetson2:/opt/nvidia/deepstream/deepstream/sources/apps/sample_apps/my-app$ GST_DEBUG=3 gst-launch-1.0 playbin uri=rtsp://127.0.0.1:8554/stream1
      Setting pipeline to PAUSED ...
      Pipeline is live and does not need PREROLL ...
      Progress: (open) Opening Stream
      Progress: (connect) Connecting to rtsp://127.0.0.1:8554/stream1
      Progress: (open) Retrieving server options
      Progress: (open) Retrieving media info
      0:00:00.102916883 19618   0x5589ed8280 WARN                 rtspsrc gstrtspsrc.c:6161:gst_rtspsrc_send:<source> error: Unhandled error
      0:00:00.103013750 19618   0x5589ed8280 WARN                 rtspsrc gstrtspsrc.c:6161:gst_rtspsrc_send:<source> error: Service Unavailable (503)
      0:00:00.103385859 19618   0x5589ed8280 WARN                 rtspsrc gstrtspsrc.c:7548:gst_rtspsrc_open:<source> can't get sdp
      ERROR: from element /GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0/GstRTSPSrc:source: Unhandled error
      0:00:00.103474726 19618   0x5589ed8280 WARN                 rtspsrc gstrtspsrc.c:5628:gst_rtspsrc_loop:<source> we are not connected
      Additional debug info:
      gstrtspsrc.c(6161): gst_rtspsrc_send (): /GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0/GstRTSPSrc:source:
      Service Unavailable (503)
      ERROR: pipeline doesn't want to preroll.
      Setting pipeline to PAUSED ...
      Setting pipeline to READY ...
      Setting pipeline to NULL ...
      Freeing pipeline ...
    
  • it doesn’t run but look what happens to rtsp_server.py after I run this command. A new element is created by rtsp_server.py each time I run this gstreamer command:

      nvidia@jetson2:/opt/nvidia/deepstream/deepstream-5.0/sources/apps/sample_apps/my-app$ python3 rtsp_server.py
      Element created: filesrc location=streamer/Vehicle.Target.Sample_EO.ts ! qtdemux name=demux demux.video_0 ! queue ! rtph264pay name=pay0 config-interval=1 pt=96
    

============================================================

Questions

  • This seems quite straightforward and it works for a videotestsrc, so where may I investigate to see why it doesn’t work with a .ts file?

  • How can I properly install gst-validate-1.0? I installed all normal packages from the gstreamer installation page (gstreamer has been working for a while now) and also installed the .tar.xz files located here (https://gstreamer.freedesktop.org/) with this command:

      sudo tar Jxvf [package-name.tar.xz]
    

I cannot use gst-validate-1.0 playbin uri=file:///path/to/some/media/file it only gives this:

    nvidia@jetson2:/opt/nvidia/deepstream/deepstream/sources/apps/sample_apps/my-app/streamer$ gst-validate-1.0 Vehicle.Target.Sample_EO.ts
    
        -bash: gst-validate-1.0: command not found

Thanks for reading and your help is much appreciated!

Hi,
We have existing implementation in sink group. Please check development guide.
Suggest modify config file to enable it and try.