How to publish x264 encode data to rtmpsink in gstreamer?

First, I try this:
gst-launch-1.0 -v videotestsrc ! avenc_flv ! flvmux ! rtmpsink location=‘rtmp://192.168.1.108/live/livestream live=1’

and it can work successfully.

However, when I try to publish x264 encode data, it failed:

gst-launch-1.0 videotestsrc ! ‘video/x-raw, format=(string)I420, width=(int)640, height=(int)480’ ! omxh264enc ! ‘video/x-h264, stream-format=(string)byte-stream’ ! h264parse ! qtmux ! rtmpsink location=‘rtmp://192.168.1.108/live/livestream live=1’

the error is that:
could not link qtmux0 to rtmpsink0.

gst-launch-1.0 -v videotestsrc ! omxh265enc ! ‘video/x-h265,stream-format=(string)byte-stream’ ! rtmpsink location=‘rtmp://192.168.1.108/live/livestream live=1’

This is also a wrong code, the error is that:
could not link omxh265enc-moxh265enc0 to rtmpsink0.

If you look at rtmpsink capabilities, you’ll see that it accepts video/x-flv as input:

gst-inspect-1.0 rtmpsink
Factory Details:
  Rank                     primary (256)
  Long-name                RTMP output sink
  Klass                    Sink/Network
  Description              Sends FLV content to a server via RTMP
  Author                   Jan Schmidt <thaytan@noraisin.net>
...
Pad Templates:
[b]  SINK template: 'sink'
    Availability: Always
    Capabilities:
      video/x-flv[/b]

You can use flvmux in order to provide this to rtmpsink. If you look at flvmux sink (input) capabilities:

gst-inspect-1.0 flvmux
Factory Details:
  Rank                     primary (256)
  Long-name                FLV muxer
  Klass                    Codec/Muxer
  Description              Muxes video/audio streams into a FLV stream
  Author                   Sebastian Dröge <sebastian.droege@collabora.co.uk>

...

Pad Templates:
  SINK template: 'video'
    Availability: On request
      Has request_new_pad() function: gst_flv_mux_request_new_pad
    Capabilities:
      video/x-flash-video
      video/x-flash-screen
      video/x-vp6-flash
      video/x-vp6-alpha
[b]      video/x-h264
          stream-format: avc[/b]

you’ll see it expects a h264 stream in avc format.

So you may just try something like:

gst-launch-1.0 -v videotestsrc ! omxh264enc ! 'video/x-h264,stream-format=(string)avc' ! flvmux ! rtmpsink location='rtmp://192.168.1.108/live/livestream live=1'

Thanks for Honey_Patouceul’s reply!

I also want to know how to publish x265 encode data. It seems that flvmux doesn’t support x-h265 as its Capabilities.

Following on flvmux with h265 as well - did you find out anything about getting rtmp working with h265 ? cheers