Streaming h264 with tcpserversink and tcpclientsrc

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Streaming h264 with tcpserversink and tcpclientsrc

Monyz Wacon
Hello,
I'm trying to stream h264 using tcrpserversink and tcpclientsrc.

Using this example I'm able to see a test stream:

gst-launch-1.0 videotestsrc ! x264enc ! video/x-h264,format=bytestream ! typefind ! h264parse ! avdec_h264 ! autovideosink

However these commands don't work as expected:

gst-launch-1.0 videotestsrc ! x264enc ! tcpserversink port=7001

gst-launch-1.0 tcpclientsrc port=7001 ! video/x-h264,format=bytestream ! typefind ! h264parse ! avdec_h264 ! autovideosink

No video is shown. The client stops at Prerolling and when I close the server, there is a message on the client's side:

ERROR: from element /GstPipeline:pipeline0/GstH264Parse:h264parse0: No valid frames found before end of stream

How to make this tcpserversink example work?

Best regards

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Streaming h264 with tcpserversink and tcpclientsrc

Peter Maersk-Moller-2
Hi Monyz.

In general you need to set the 'is-live' parameter to 'true' for videotestsrc. Otherwise your pipeline will generate as many frames per second as your hardware supports and that is probably not what you want. The reason your first example with autovideosink is that the videosink will limit how many frames per second you can display and that will ripple back from the videosink to the videotestsrc. Lack of CPU capacity might also slow down the number of frames.

Now to streaming using tcpserversink. You can in general not stream a raw encoded video stream. You need to place the raw stream into a media container. A media container could be RTP, TS, AVI, MP4, Matroska and many more.

Something similar to this will work

  gst-launch-1.0 -v videotestsrc is-live=true ! video/x-raw,width=640,width=480,framerate=30/1 ! queue ! videoconvert ! x264enc tune=zero-latency ! h264parse ! queue ! matroskamux ! queue leaky=2 ! tcpserversink port=7001 host=0.0.0.0 recover-policy=keyframe sync-method=latest-keyframe

Technically you can eliminate the video caps, if you only want the default values. You can also eliminate one of the queues, but I placed it there for a reason. You can also eliminate videoconvert, but like the extra queue, I placed it there for a reason. The leaky queue is actually also intentionally. In most cases you won't need it, but in some cases with an extended pipeline, you need it to avoid everything locking up in case your client is slow at picking up data. Complicated. Just add it.

The client is simple.

  gst-launch -v tcpclientsrc host=a.b.c.d port=7001 ! decodebin ! autovideosink

On Thu, Jun 2, 2016 at 10:22 PM, Monyz Wacon <[hidden email]> wrote:
Hello,
I'm trying to stream h264 using tcrpserversink and tcpclientsrc.

Using this example I'm able to see a test stream:

gst-launch-1.0 videotestsrc ! x264enc ! video/x-h264,format=bytestream ! typefind ! h264parse ! avdec_h264 ! autovideosink

However these commands don't work as expected:

gst-launch-1.0 videotestsrc ! x264enc ! tcpserversink port=7001

gst-launch-1.0 tcpclientsrc port=7001 ! video/x-h264,format=bytestream ! typefind ! h264parse ! avdec_h264 ! autovideosink

No video is shown. The client stops at Prerolling and when I close the server, there is a message on the client's side:

ERROR: from element /GstPipeline:pipeline0/GstH264Parse:h264parse0: No valid frames found before end of stream

How to make this tcpserversink example work?

Best regards

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Streaming h264 with tcpserversink and tcpclientsrc

Tim Müller
In reply to this post by Monyz Wacon
On Thu, 2016-06-02 at 21:22 +0100, Monyz Wacon wrote:

Hi,

> I'm trying to stream h264 using tcrpserversink and tcpclientsrc.
>
> Using this example I'm able to see a test stream:
>
> gst-launch-1.0 videotestsrc ! x264enc ! video/x-
> h264,format=bytestream ! typefind ! h264parse ! avdec_h264 !
> autovideosink

I think this should be: video/x-h264,stream-format=byte-stream


> However these commands don't work as expected:
>
> gst-launch-1.0 videotestsrc ! x264enc ! tcpserversink port=7001

Pass -v to gst-launch-1.0 to see what video/x-h264 stream-format
x264enc negotiates to here. It might depend on your GStreamer version.
In newer versions it will hopefully use byte-stream (which is fine
here), but in older versions it might end up outputting avc which won't
work over tcp.

You can force it to output byte-stream format with


 ... ! x264enc ! video/x-h264,stream-format=byte-stream ! tcpserversink


> gst-launch-1.0 tcpclientsrc port=7001 ! video/x-
> h264,format=bytestream ! typefind ! h264parse ! avdec_h264 !
> autovideosink

See above, but also: just tcpclientsrc ... ! typefind should be enough,
there's no need to tell typefind what the format is, it should figure
it out itself. Again, pass -v to gst-launch-1.0 to see what's
happening. typefind should detect h264 byte-stream format.


One problem with this is that there won't be proper timestamping like
this, but at least you should see an initial image. Putting the stream
in a container such as matroska or mpeg-ts might be a good idea.

Cheers
 -Tim

--
Tim Müller, Centricular Ltd - http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel