[Live-devel] How to play a MPEG2-TS (H264 transport stream) live stream

Ross Finlayson finlayson at live555.com
Tue Apr 12 17:50:56 PDT 2016


> 
> I am trying to figure out where the problme is in my modified testRTSPClient.cpp. The concerned line of code are the following:
> 
> 
> void continueAfterSETUP(RTSPClient* rtspClient, int resultCode, char* resultString) {
>   ...
> 
>   scs.framer = H264VideoStreamDiscreteFramer::createNew(env, scs.subsession->readSource());

You don’t need this.  Generally speaking, a “H264VideoStreamDiscreteFramer” is used only if you are about to transmit H.264 video, not if you’ve just received it.  (And a “H264VideoStreamFramer” would be wrong, because that’s used only to parse a H.264 video byte stream, not discrete NAL units (which is what you have).)

The problem is that - for H.264 - the NAL units that you feed into a “MPEG2TransportStreamFromESSource” must each begin with a 4-byte ‘start code’ (0x00 0x00 0x00 0x01).  Therefore, you need a new “FramedFilter” subclass - that you would write - that prepends this ‘start code’ to each NAL unit, before passing it to “MPEG2TransportStreamFromESSource”.  I.e., you need:

	scs.subsession->readSource() => your-filter-that-adds-a-start-code => MPEG2TransportStreamFromESSource
and then
	sink->startPlaying()
as before.

ALTERNATIVELY (and MUCH simpler), you can modify “testH264VideoToTransportStream.cpp” to change the “inputFileName” variable from
	“in.ts”
to
	“stdin”
and then just run
	openRTSP -v rtsp://url | your-modified-testH264VideoToTransportStream
to get a Transport Stream file named “out.ts”.  I.e., just pipe the stdout from “openRTSP -v” to your modified “testH264VideoToTransportStream”.


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




More information about the live-devel mailing list