mpeg2 to HLS on a Raspberry Pi - Missing SPS/PPS before keyframe

Graham Leggett minfrin at sharp.fm
Sun Jul 26 17:00:02 PDT 2015


Hi all,

Using the following pipeline I am capturing video from a multicasted mpeg2 stream and am trying to transcode it to HLS on a Raspberry Pi using gstreamer v1.2.4:

gst-launch-1.0 -v udpsrc port=5004 multicast-group=239.255.1.30 caps="application/x-rtp,media=(string)video,clock-rate=(int)90000" ! rtpbin ! rtpmp2tdepay ! tsdemux name=demux ! mpegvideoparse ! omxmpeg2videodec ! queue ! videoconvert ! deinterlace ! videoscale ! video/x-raw,width=960,height=540 ! omxh264enc target-bitrate=5000000 control-rate=variable inline-header=true periodicty-idr=50 interval-intraframes=50 ! queue ! mpegtsmux name=mux ! hlssink location=/var/www/stream/segment2%05d.ts playlist-location=/var/www/stream/output2.m3u8 playlist-root=http://192.168.225.2/stream/ target-duration=2  demux. ! mpegaudioparse ! mpg123audiodec ! audioconvert ! audioresample ! voaacenc ! queue ! mux.

The resulting HLS plays in VLC, but the video remains black in both Safari and iOS. An analysis using Adobe’s Primetime Stream validation service indicates the rendered TS is broken as follows:

Missing SPS/PPS before keyframe

Turns out missing SPS/PPS is a common problem on the Pi, but none of the solutions I have tried have worked. In theory the "inline-header=true periodicty-idr=50 interval-intraframes=50” parameters to omxh264enc should cause SPS/PPS packets to be generated, but this doesn’t seem to be happening. There are no warnings or errors to indicate there is any problem such as invalid parameters, they appear in the gst-inspect output as expected.

Further googling reveals that adding "h264parse config-interval=1” should in theory add the missing SPS/PPS packets, but the effect of adding h264parse breaks hlssink - no m3u8 file is ever written, and the first ts file grows without bound:

gst-launch-1.0 -v udpsrc port=5004 multicast-group=239.255.1.30 caps="application/x-rtp,media=(string)video,clock-rate=(int)90000" ! rtpbin ! rtpmp2tdepay ! tsdemux name=demux ! mpegvideoparse ! omxmpeg2videodec ! queue ! videoconvert ! deinterlace ! videoscale ! video/x-raw,width=960,height=540 ! omxh264enc target-bitrate=5000000 control-rate=variable inline-header=true periodicty-idr=50 interval-intraframes=50 ! h264parse config-interval=1 ! queue ! mpegtsmux name=mux ! hlssink location=/var/www/stream/segment2%05d.ts playlist-location=/var/www/stream/output2.m3u8 playlist-root=http://192.168.225.2/stream/ target-duration=2  demux. ! mpegaudioparse ! mpg123audiodec ! audioconvert ! audioresample ! voaacenc ! queue ! mux.

I am very new to gstreamer and so I don’t fully understand if I am doing something fundamentally wrong or if I have found a bug in omxh264enc , h264parse, or hlssink.

Can anyone shed some light on this?

Regards,
Graham
—



More information about the gstreamer-devel mailing list