Stream MKV file using H264 compression and RTP

Using gstreamer on Nvidia Jetson Nano, I want to read from MKV file and encode it as H264 to stream via RTP. I successfully did it with MP4 file this way:

gst-launch-1.0 filesrc location=$file ! decodebin ! videoconvert ! omxh264enc ! video/x-h264, width=1280, height=720, format=I420, stream-format=byte-stream ! rtph264pay ! udpsink host=127.0.0.1 port=5000

But when I wanted to parse MKV, I received errors, so I tried this:

gst-launch-1.0 filesrc location=$file ! matroskademux ! videoconvert ! omxh264enc ! video/x-h264, width=1280, height=720, format=I420, stream-format=byte-stream ! rtph264pay ! udpsink host=127.0.0.1 port=5000

Then I received an error:

./grammar.y(510): gst_parse_no_more_pads ():
/GstPipeline:pipeline0/GstMatroskaDemux:matroskademux0:
failed delayed linking some pad of GstMatroskaDemux named matroskademux0 to some pad of GstVideoConvert named videoconvert0
ERROR: from element /GstPipeline:pipeline0/GstMatroskaDemux:matroskademux0: Internal data stream error.
Additional debug info:
matroska-demux.c(5213): get_matroska_demux_loop (): /GstPipeline:pipeline0/GstMatroskaDemux:matroskademux0:
streaming stopped, reason not-linked (-1)

I then tried removing the videoconvert pipe and go straight to encoding H264, but it didnā€™t work also.

What is the correct approach pipelining it?

Hi,
Please refer to this pipeline:

$ gst-launch-1.0 filesrc location=test.mkv ! matroskademux ! h264parse config-interval=1 ! rtph264pay ! udpsink host=127.0.0.1 port=5000

Thank you.
Unfortunately that didnā€™t help, I still get an error:

nvidia@nvidia-desktop:~$ gst-launch-1.0 filesrc location=ā€œ/home/nvidia/Videos/10 Incredible 4K (Ultra HD) Videos.mkvā€ ! matroskademux ! h264parse config-interval=1 ! rtph264pay ! udpsink host=127.0.0.1 port=5000
Setting pipeline to PAUSED ā€¦
Pipeline is PREROLLING ā€¦
WARNING: from element /GstPipeline:pipeline0/GstMatroskaDemux:matroskademux0: Delayed linking failed.
Additional debug info:
./grammar.y(510): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstMatroskaDemux:matroskademux0:
failed delayed linking some pad of GstMatroskaDemux named matroskademux0 to some pad of GstH264Parse named h264parse0
ERROR: from element /GstPipeline:pipeline0/GstMatroskaDemux:matroskademux0: Internal data stream error.
Additional debug info:
matroska-demux.c(5213): gst_matroska_demux_loop (): /GstPipeline:pipeline0/GstMatroskaDemux:matroskademux0:
streaming stopped, reason not-linked (-1)
ERROR: pipeline doesnā€™t want to preroll.
Setting pipeline to NULL ā€¦
Freeing pipeline ā€¦

Hi,
Please try the files in https://jell.yfish.us/
Not sure but it seems like the failure is specific to 10 Incredible 4K (Ultra HD) Videos.mkv

Youā€™re right, these files adhere to the pipeline you wrote.
Can I please know how to decode it back?

This is what I tried:

gst-launch-1.0 udpsrc port=5000 ! rtph264depay ! omxh264dec ! nveglglessink -e
and also

gst-launch-1.0 udpsrc port=5000 ! rtph264depay ! h264parse ! omxh264dec ! nveglglessink -e

and the error returned was:

Setting pipeline to PAUSED ā€¦
Using winsys: x11
Pipeline is live and does not need PREROLL ā€¦
Got context from element ā€˜eglglessink0ā€™: gst.egl.EGLDisplay=context, display=(GstEGLDisplay)NULL;
Setting pipeline to PLAYING ā€¦
New clock: GstSystemClock
ERROR: from element /GstPipeline:pipeline0/GstRtpH264Depay:rtph264depay0: No RTP format was negotiated.
Additional debug info:
gstrtpbasedepayload.c(458): gst_rtp_base_depayload_handle_buffer (): /GstPipeline:pipeline0/GstRtpH264Depay:rtph264depay0:
Input buffers need to have RTP caps set on them. This is usually achieved by setting the ā€˜capsā€™ property of the upstream source element (often udpsrc or appsrc), or by putting a capsfilter element before the depayloader and setting the ā€˜capsā€™ property on that. Also see README\rtp\gst - gstreamer/gst-plugins-good - 'Good' GStreamer plugins (mirrored from https://gitlab.freedesktop.org/gstreamer/gst-plugins-good)
EOS on shutdown enabled ā€“ waiting for EOS after Error
Waiting for EOSā€¦
ERROR: from element /GstPipeline:pipeline0/GstUDPSrc:udpsrc0: Internal data stream error.
Additional debug info:
gstbasesrc.c(3055): gst_base_src_loop (): /GstPipeline:pipeline0/GstUDPSrc:udpsrc0:
streaming stopped, reason not-negotiated (-4)

This is done from the same Nano, so why is it not working?

Adding some progress - I got rid of the error by including ā€˜capsā€™ property:

gst-launch-1.0 udpsrc port=5000 caps = ā€œapplication/x-rtp, media=video, clock-rate=90000, payload=96ā€ ! rtph264depay ! omxh264dec ! nvglglessink -e

Then it seems to accept it, shows that pipeline is PLAYING and ending with ā€œNew clock: GstSystemClockā€ line,
but doesnā€™t show anything on my screen.

So Iā€™m still baffled.

Hi,
Please try

gst-launch-1.0 udpsrc port=5000 caps = "application/x-rtp, media=video, clock-rate=90000, payload=96" ! rtph264depay ! h264parse ! nvv4l2decoder ! nvoverlaysink

Hi, thanks again for the quick reply.
It thinks it is playing, but nothing is showing on the screen.
After a few seconds a critical error message appears.
Hereā€™s the output:

Setting pipeline to PAUSED ā€¦
Opening in BLOCKING MODE
Pipeline is live and does not need PREROLL ā€¦
Setting pipeline to PLAYING ā€¦
New clock: GstSystemClock
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261

(gst-launch-1.0:7447): GStreamer-CRITICAL **: 08:35:21.321: gst_mini_object_unref: assertion ā€˜mini_object != NULLā€™ failed
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261
^Chandling interrupt.
Interrupt: Stopping pipeline ā€¦
Execution ended after 0:00:12.776136026
Setting pipeline to PAUSED ā€¦
Setting pipeline to READY ā€¦
Setting pipeline to NULL ā€¦
Freeing pipeline ā€¦

Iā€™m really sorry to trouble you with this.
I really read the Gstreamer user guide and examples and gazillion forum topics, but none seem to produce the result that Iā€™m after.

Perhaps, you could show me the correct pipeline from server to client to play a simple 4k mkv file from jellyfish over rtp/udp?

Hi,
Would like to get more information about the use-case. Do you put MKV files in Jetson Nano as a server and other devices can connect to Jetson Nano and play the MKV files?

As a first stage, I put the MKV files on the Jetson Nano, and I want to be able to stream them over RTP/UDP and play them using HW decoding on the Nano itself.

Second stage will be to receive the stream from an outside source, like a camera (MIPI), using HW encoding over RTP/UDP to another Jetson Nano on the network, which will decode and play.

Hi,
It might be better to run a RTSP server on Jetson Nano as on-demand service. Please check steps in
Jetson Nano FAQ
[Q: Is there any example of running RTSP streaming?]

On Jetson Nano you can run:

$ ./test-launch "filesrc location=jellyfish-5-mbps-hd-h264.mkv ! matroskademux ! h264parse config-interval=-1 ! rtph264pay name=pay0 pt=96"

On another device, you can use VLC player or run a gstreamer command to open the link.

Thanks a lot! I appreciate your answers very much!

How can I affect the outgoing stream resolution?
I want to stream 2 types of streams - one of 4K and one of 720p - and test the CPU usage and power consumption while encoding it to H264 over RTSP

Hi,
test-launch is a test sample and it can only construct one connection. For multiple connections with different resolutions, would need other users to share experience about implementing the use-case.

2 Likes

I managed to stream twice in two different ports. I just donā€™t know how to change resolution and stream in HW encoding of my choosingā€¦This is so hard, this device is very frustrating.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.