[Live-devel] Demux live MPEGTS multicast stream and feed it to RTSP server

Ross Finlayson finlayson at live555.com
Wed Mar 17 13:30:59 PDT 2021


Josh,

I think you’re on the right track.  Try the following to be sure:

> I have setup the onDemandRtspServer example with the MPEG2TransportUDPServerMediaSubsession and it is working flawlessly with VLC, ffmpeg, and the openRTSP clients.

Good.  Now run “openRTSP” for a while, to receive a Transport Stream file from your input source, and rename the resulting output file “test.ts”.  Make sure that this file “test.ts” can be played OK by VLC.

Then run:
	testMPEG2TransportStreamSplitter < test.ts

Check that this produces a non-empty video file (named “VIDEO-<something>”)?

(Note that you could have combined the above two steps by running:
	openRTSP -v rtsp://URL | testMPEG2TransportSplitter
 (replace "rtsp://URL” with your URL) to get your video file, without generating an intermediate file “test.ts".)

Your video file should be a H.264 video file.  To be sure, try renaming it to “test.h264”, and try playing that file with VLC.  This might not work (because of a bug in recent versions of VLC); if not, then run the following:
	ffmpeg -i test.h264 -c copy test.mp4
and then try playing “test.mp4” with VLC instead.

If you don’t get this far, then let us know, and don’t proceed any further.  Otherwise, continue…


> I am now looking into how to demux the live incoming MPEGTS stream and pull out the h264 data and pack that into RTP packets and send it to clients. I have investigated the testMPEG2TrabsportStreamSplitter, however, I haven't been able to get it to work with the BasicUDPSource. Here is the flow I currently have set up:
> 
> MPEGTS Multicast Stream -----> BasicUDPSource ----> MPEG2TransportStreamFramer -----> MPEG2TransportStreamDemux

You don’t need a “MPEG2TransportStreamFramer”; that’s used only to generate presentation times for the resulting Transport Stream (188-byte) frames, but the “MPEG2TransportStreamDemux” doesn’t need those presentation times.  Instead, try:
	MPEGTS Multicast Stream -----> BasicUDPSource ----> MPEG2TransportStreamDemux

If that doesn’t work (i.e., you end up with an empty output file), then the problem might be that the UDP source is generating chunks of Transport Stream data that’s too small for “MPEG2TransportStreamDemux” to properly handle.  Try the following instead:
	MPEGTS Multicast Stream -----> BasicUDPSource ----> MPEG2TransportStreamAccumulator ----> MPEG2TransportStreamDemux
(You may need to add
	#include “MPEG2TransportStreamAccumulator.hh”
 to the start of your code to get the definition of the “MPEG2TransportStreamAccumulator” class.)

If you can get this far, let us know.  I would need to change the “MPEG2TransportStreamDemux” (i.e., in a new version of the LIVE555 code) to allow you to feed your output stream into a RTSP server (rather than just writing it to a file), but I want to first be sure that you’re able to get this far.


Ross Finlayson
Live Networks, Inc.
http://www.live555.com/




More information about the live-devel mailing list