0

I am trying to simulate sending and receiving mpeg video with gst-launch-1.0.

Sender pipeline: gst-launch-1.0 videotestsrc ! video/x-raw,width=1920,height=1080,framerate=15/1 ! queue ! x264enc bitrate=4000 ! queue ! mpegtsmux ! rtpmp2tpay ! udpsink host=224.10.10.10 port=15004

Receiver pipeline: gst-launch-1.0 -v rtpbin name=rtpbin udpsrc caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)MP2T,payload=(int)33,seqnum-offset=(uint)2803,timestamp-offset=(uint)2170591411, ssrc=(uint)2276926567" port=15004 multicast-group=224.10.10.10 ! rtpbin.recv_rtp_sink_0 rtpbin. ! rtpmp2tdepay ! tsdemux ! h264parse ! capsfilter caps=video/x-h264,alignment=au,stream-format=avc ! avdec_h264 ! fpsdisplaysink sync=1 udpsrc port=18889 ! rtpbin.recv_rtcp_sink_0

deducted from: gst-launch-1.0 -v rtpbin name=rtpbin udpsrc caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)MP2T,payload=(int)33,seqnum-offset=(uint)2803,timestamp-offset=(uint)2170591411, ssrc=(uint)2276926567" port=15004 multicast-group=224.10.10.10 ! rtpbin.recv_rtp_sink_0 rtpbin. ! rtpmp2tdepay ! tsdemux ! decodebin ! fpsdisplaysink sync=1 udpsrc port=18889 ! rtpbin.recv_rtcp_sink_0

Running the receiver first, then the sender results as expected displaying video window immediately.

But when the sender is launched first, receiever pipeline hangs for about 10 seconds displaying lots of those messages:

0:00:01.654820616 23285 0x56008c3bb640 WARN               h264parse gsth264parse.c:1349:gst_h264_parse_handle_frame:<h264parse0> broken/invalid nal Type: 1 Slice, Size: 32773 will be dropped

gst-launch-1.0 --gst-version returns:

GStreamer Core Library version 1.16.2
Kyeiv
  • 63
  • 8

1 Answers1

1

I think it is similar to my question here. This error is being thrown because your h264parse element has not yet received the SPS/PPS data.

The warning is thrown from here:

if (!gst_h264_parse_process_nal (h264parse, &nalu)) {
  GST_WARNING_OBJECT (h264parse,
      "broken/invalid nal Type: %d %s, Size: %u will be dropped",
      nalu.type, _nal_name (nalu.type), nalu.size);
  [...]
}

For a slice, this fails here:

    case GST_H264_NAL_SLICE:
    case GST_H264_NAL_SLICE_DPA:
    case GST_H264_NAL_SLICE_DPB:
    case GST_H264_NAL_SLICE_DPC:
    case GST_H264_NAL_SLICE_IDR:
    case GST_H264_NAL_SLICE_EXT:
      /* expected state: got-sps|got-pps (valid picture headers) */
      h264parse->state &= GST_H264_PARSE_STATE_VALID_PICTURE_HEADERS;
      if (!GST_H264_PARSE_STATE_VALID (h264parse,
              GST_H264_PARSE_STATE_VALID_PICTURE_HEADERS))
        return FALSE;

I think this happens because when you start the sender first, then the SPS/PPS frames are emitted before the receiver starts, and therefore are lost for a while. You could try to make the sender emit this data more often. I think for instance h264parse config-interval=-1 would send it with every IDR frame.

JonasVautherin
  • 7,297
  • 6
  • 49
  • 95