# Unable to get mpegts with klv-metadata to flow to end of pipe from udpsrc

**URL:** <https://discourse.gstreamer.org/t/unable-to-get-mpegts-with-klv-metadata-to-flow-to-end-of-pipe-from-udpsrc/516>\
**Category:** Application Development\
**Created:** [November 10, 2023, 8:58am UTC](https://discourse.gstreamer.org/t/unable-to-get-mpegts-with-klv-metadata-to-flow-to-end-of-pipe-from-udpsrc/516 "2023-11-10T08:58:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hippakaveri](https://discourse.gstreamer.org/user_avatar/discourse.gstreamer.org/hippakaveri/32/234_2.png) [@Hippakaveri](https://discourse.gstreamer.org/u/Hippakaveri)\
**Post date:** [November 10, 2023, 8:58am UTC](https://discourse.gstreamer.org/t/unable-to-get-mpegts-with-klv-metadata-to-flow-to-end-of-pipe-from-udpsrc/516/1 "2023-11-10T08:58:41Z")

</div>

Hi, I’ve been fighting with this problem for quite a while now. I have mpegts stream with klv-metadata coming from udpsrc and the bellow gstreamer command to handle it and to pass it through to rtspclientsink.

```auto
   gst-launch-1.0 -e udpsrc address=224.1.1.1 reuse=true port=50088 socket-timestamp=1 buffer-size=100000000 ! 'video/mpegts, systemstream=(boolean)true, packetsize=(int)188' !
        queue max-size-time=1700000000 max-size-buffers=50 ! tsparse set-timestamps=true ! 
        tsdemux parse-private-sections=true ignore-pcr=true name=demux
        demux. ! queue max-size-time=0 max-size-buffers=0 ! decodebin use-buffering=true ! videoconvert ! videorate ! videoscale ! x264enc tune=zerolatency bitrate=5500 key-int-max=30 ! mpegtsmux name=mux
        demux. ! queue max-size-time=0 max-size-buffers=0 ! meta/x-klv ! mux. mux. ! rtspclientsink location=rtsp://127.0.0.1:8554/testpath 

```

If I switch the udpsrc to a filesrc ([Index of /MPEG2/mpegts-klv](https://samples.ffmpeg.org/MPEG2/mpegts-klv/) ← either of the files should work), the whole pipe works just fine.

But after I switch it to udpsrc, I only get a few frames worth of klv-data after EOS, other times I keep getting “WARNING: from element /GstPipeline:pipeline0/GstTSDemux:demux: CONTINUITY: Mismatch packet” .

I’ve used below ffmpeg command to forward the rtsp back to udp

```auto
ffmpeg -i rtsp://127.0.0.1:8554/testpath -map 0 -c copy -f mpegts udp://224.1.1.1:50068

```

and then I have used bellow command to listen to above udp forwarding.

```auto
gst-launch-1.0 -v -e udpsrc address=224.1.1.1 reuse=true port=50068 ! 'video/mpegts, systemstream=(boolean)true, packetsize=(int)188' ! tsdemux name=demux demux. ! queue ! h264parse ! 'video/x-h264, stream-format=byte-stream, alignment=au' ! avdec_h264 ! autovideosink demux. ! queue ! 'meta/x-klv' ! fdsink

```

And like I said the whole flow works with filesrc in the beginning, but with udpsrc it doesn’t.

All help is much appreciated.  
Thanks already.

Edit: My assumption is that there’s lot less klv-data in the ffmpeg files than the file I’m using (which I can’t share), that the fdsink pipe doesn’t work with it. But managed to write the data to a file using following

```auto
gst-launch-1.0 -e udpsrc address=224.1.1.1 port=50088 ! tsdemux name=demux demux. ! queue ! meta/x-klv ! filesink location=klv_output_night.bin
type or paste code here

```
