GStreamer shmsink 断言 'segment->format == format' 失败

GStreamer shmsink assertion 'segment->format == format' failed

我使用 OpenCV VideoWriter 元素在我的程序中有以下管道 运行。

gst-launch-1.0 -v videotestsrc ! clockoverlay ! shmsink socket-path=/tmp/sink shm-size=2000000 name=/dev/shm wait-for-connection=false

当我通过以下管道使用流时一切正常

gst-launch-1.0 -v shmsrc is-live=true socket-path=/tmp/sink shm-area-name=/dev/shm ! \
    "video/x-raw, format=BGR, width=(int)160, height=(int)120, framerate=(fraction)30/1" ! \
    queue ! videoconvert ! autovideosink

但是当我尝试使用以下管道对流进行 h264 编码时

gst-launch-1.0 -vvv shmsrc is-live=true socket-path=/tmp/sink shm-area-name=/dev/shm ! \
    "video/x-raw, format=BGR, width=(int)160, height=(int)120, framerate=(fraction)30/1" ! \
    queue ! videoconvert ! x264enc bitrate=1000 ! video/x-h264,profile=baseline ! \
    rtph264pay config-interval=1 pt=96 ! queue ! udpsink host=127.0.0.1 port=5000

我明白了

(gst-launch-1.0:8119): GStreamer-CRITICAL **: gst_segment_to_running_time: assertion 'segment->format == format' failed

而且我从 VLC 中看不到任何内容。我错过了什么?

注意:要重现问题,可以使用以下 producer/consumer 管道:

gst-launch-1.0 -v videotestsrc ! clockoverlay ! shmsink socket-path=/tmp/sink shm-size=2000000 name=/dev/shm wait-for-connection=false
sudo gst-launch-1.0 -vvv shmsrc is-live=true socket-path=/tmp/sink shm-area-name=/dev/shm ! \
    "video/x-raw, format=BGR, width=(int)160, height=(int)120, framerate=(fraction)30/1" ! \
    queue ! videoconvert ! x264enc bitrate=1000 ! video/x-h264,profile=baseline ! rtph264pay config-interval=1 pt=96 ! queue ! udpsink host=127.0.0.1 port=5000

系统信息

终于找到了 this 篇文章,帮助我解决了问题。

我的最终管道如下所示。

生产者管道

gst-launch-1.0 -v videotestsrc is-live=true ! clockoverlay ! shmsink socket-path=/tmp/sink shm-size=2000000 name=/dev/shm sync=true wait-for-connection=false

消费者管道

gst-launch-1.0 -vvv shmsrc is-live=true do-timestamp=true socket-path=/tmp/sink shm-area-name=/dev/shm ! \
    "video/x-raw, format=BGR, width=(int)160, height=(int)120, framerate=(fraction)30/1" ! \
    queue ! videoconvert ! x264enc bitrate=1000 ! video/x-h264,profile=baseline ! rtph264pay config-interval=1 pt=96 ! queue ! udpsink host=192.168.200.255 port=5000 sync=false