Gstreamer 管道 - 在单独的进程中生产和使用输出

Gstreamer pipeline - produce and consume output in separate processes

我想要两个独立的 gstreamer 管道,一个产生视频输出,另一个使用它。 生产者在 Docker 容器中,消费者在主机上 运行。 为此,我正在尝试让可以想象的最基本的东西工作使用 gst-launch 工具,但无论如何我都无法让它工作。例如,这在接收端失败 ERROR: from element /GstPipeline:pipeline0/GstRtpVRawDepay:rtpvrawdepay0: No RTP format was negotiated.:

# process to produce video stream:
gst-launch-1.0 --gst-debug-level=3 \
  videotestsrc ! videoconvert \
  ! rtpvrawpay ! udpsink host=127.0.0.1 port=5600

# process to consume it (and display it):
gst-launch-1.0 --gst-debug-level=3 \
  udpsrc port=5600 \
  ! rtpvrawdepay ! videoconvert ! autovideosink

...令我感到困惑的是,我确实设法开始使用看似复杂得多的设置:

# produce:
gst-launch-1.0 filesrc location=/path/to/my.mp4 \
  ! decodebin ! videoconvert \
  ! x264enc tune=zerolatency \
  ! rtph264pay \
  ! udpsink host=127.0.0.1 port=5600

# consume:
gst-launch-1.0 -vc udpsrc port=5600 close-socket=false multicast-iface=false auto-multicast=true \
  ! application/x-rtp, payload=96 ! rtpjitterbuffer ! rtph264depay ! avdec_h264 \
  ! fpsdisplaysink  sync=false async=false --verbose

(注意:第二个示例中的特殊接收器类型无关紧要,使用 autovideosink 也可以正常工作。)

看来您想在同一台主机上执行此操作。太好了,这样我们就可以忘记网络协议和传输的复杂性了。

GStreamer 提供了不同的方法来做到这一点。我建议看看 gdp 插件:

Plugin Details:
  Name                     gdp
  Description              Payload/depayload GDP packets
  Filename                 /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstgdp.so
  Version                  1.16.0
  License                  LGPL
  Source module            gst-plugins-bad
  Source release date      2019-04-19
  Binary package           GStreamer Bad Plugins (Debian)
  Origin URL               http://packages.qa.debian.org/gst-plugins-bad1.0

  gdpdepay: GDP Depayloader
  gdppay: GDP Payloader

  2 features:
  +-- 2 elements

结合shm插件:

Plugin Details:
  Name                     shm
  Description              shared memory sink source
  Filename                 /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstshm.so
  Version                  1.16.0
  License                  LGPL
  Source module            gst-plugins-bad
  Source release date      2019-04-19
  Binary package           GStreamer Bad Plugins (Debian)
  Origin URL               http://packages.qa.debian.org/gst-plugins-bad1.0

  shmsink: Shared Memory Sink
  shmsrc: Shared Memory Source

  2 features:
  +-- 2 elements

这样做可以让您在进程之间传递完整的 GstBuffer 数据。这意味着所有时间戳、标志等

所以基本上制作人会做这样的事情:

.. ! gdppay ! shmsink

和消费者:

shmsrc ! gdpdepay ! ..

相应地设置属性和套接字路径..

我想通过 filesink/filesrc 的常规 file/pipe 会起作用,但我没有尝试过..