Identify if an RTSP Stream contains PPS and SPS information

Viewed 173

I am ingesting different kinds of security camera RTSP streams with gstreamer. In most of the cases I use a pipeline similar to this

gst-launch-1.0 rtspsrc location=rtsp://<username:password@$RTSPURL> protocols=4 name=rtspsrc0 rtspsrc0. ! rtph264depay ! tee name=t t.! queue ! hlssink2 name=ingest2 playlist-length=5 max-files=10 target-duration=2 playlist-location=stream.m3u8 location=segment_%d.ts

However the Axis cameras do not seem to send SPS ansd PPS NALUs at all. In order to work around this problem I am having to use h264parse config-interval=-1 so that the SPS and PPS is inserted.

I would like to identify which streams have the SPS PPS information and the add the H264parse accordingly.

Is there a way in gstreamer, ffmpeg/ffprobe to identify if PPS, SPS is sent in the packets and then add the h264parse element dynamically?

1 Answers

You can run

ffmpeg -i INPUT -an -c copy -t 10 -bsf:v trace_headers -f null - 2>&1 | grep Parameter

This will examine 10 seconds of video stream data and log all NALU data. If PS are present, you will see lines of the form

[trace_headers @ 000002951294c4c0] Sequence Parameter Set
[trace_headers @ 000002951294c4c0] 0           forbidden_zero_bit              0 = 0
[trace_headers @ 000002951294c4c0] 1           nal_ref_idc                    11 = 3

Do check the line immediately above the PS section, if it says

[trace_headers @ 000002951294c4c0] Extradata

ignore it. That can be out-of-band transmission, like from the SDP.

Related