gst-launch with tcpserversink not working

2019-09-02 06:30发布

问题:

I am trying to user gst-launch to stream mp3 audio over tcp, this is what I am trying :

$ gst-launch-0.10 filesrc location="/path/to/file.mp3" ! tcpserversink host=0.0.0.0 port=3000

but it doesn't work the output is as follow :

Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
ERROR: from element /GstPipeline:pipeline0/GstTCPServerSink:tcpserversink0: Internal GStreamer error: negotiation problem.  Please file a bug at http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer.
Additional debug info:
gstmultifdsink.c(2700): gst_multi_fd_sink_render (): /GstPipeline:pipeline0/GstTCPServerSink:tcpserversink0:
Received first buffer without caps set
Execution ended after 94657 ns.
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ..

Whats the problem where I am going wrong?

I did lots of search on internet but didn't found the right document how to use gst-launch properly. if anyone can please point me to right doc or tell me how to use it it will great.

回答1:

tcpserversink complains about missing caps on its sink pad:

Received first buffer without caps set

This is because tcpserversink wants to know what it sends.
One way to tell it would be to manually decode and re-encode the stream:

gst-launch-0.10 filesrc location="/path/to/file.mp3" ! mad ! audioconvert ! lame ! tcpserversink host=0.0.0.0 port=3000

But that's just waste of CPU power.
There's an element called mpegaudioparse that (apart from some other stuff) figures out the details of the mpeg stream and sets its output caps accordingly. By simply putting it between your filesrc and the tcpserversink you'll end up with a working pipeline:

$ gst-launch-0.10 filesrc location="/path/to/file.mp3" ! mpegaudioparse ! tcpserversink host=0.0.0.0 port=3000