简体   繁体   English

GStreamer 中的 fdsink 元素不能用于 output 正确的字节流到管道

[英]The fdsink element in GStreamer cannot be used to output the correct byte-stream to the pipeline

Because I need to output the RTSP stream pulled from the GStreamer command line to my Python program, I use the fdsink element to output the byte-stream from the pipeline.因为我需要将 output RTSP stream 从 GStreamer 命令行拉到我的 Python 程序,所以我使用fdsink元素来 output 来自管道的字节流。 The video can be displayed correctly by using the xvimagesink element.使用xvimagesink元素可以正确显示视频。 The command line is as follows.命令行如下。

gst-launch-1.0 rtspsrc location=rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4 ! queue2 ! rtph264depay ! capsfilter caps="video/x-h264, width=240, height=160" ! avdec_h264 ! videoconvert ! xvimagesink

Correct video:正确的视频: 在此处输入图像描述

Then I use fdsink instead of the xvimagesink element to output the byte stream from the pipeline and play it with ffplay.然后我使用fdsink而不是xvimagesink元素从管道到 output 字节 stream 并使用 ffplay 播放它。 It can't display correct video.它无法显示正确的视频。 The command line is as follows.命令行如下。

gst-launch-1.0 rtspsrc location=rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4 ! queue2 ! rtph264depay ! capsfilter caps="video/x-h264, width=240, height=160" ! avdec_h264 ! videoconvert ! fdsink | ffplay -f rawvideo -pixel_format rgb24 -video_size 240*160 -i -

Wrong video:错误的视频: 在此处输入图像描述

So is fdsink element wrong or other elements wrong?那么是fdsink元素错了还是其他元素错了? Thank you for taking the time to help me solve the problem感谢您抽出时间帮我解决问题

There are two issues:有两个问题:

  • GStreamer writes text messages to stdout , and FFplay interprets the text as raw pixels. GStreamer 将文本消息写入stdout ,FFplay 将文本解释为原始像素。
    Add --quiet to prevent GStreamer from writing text to stdout .添加--quiet以防止 GStreamer 将文本写入stdout

  • Default GStreamer raw video format is "planar RGB" - red plain then green plane then blue plane.默认的 GStreamer 原始视频格式是“平面 RGB”——红色平面然后是绿色平面然后是蓝色平面。
    We may convert pixel format to data ordered BGR (b,g,r,b,g,r...) by adding:我们可以通过添加:
    capsfilter caps="video/x-raw, format=BGR"


The following command plays well in my machine:以下命令在我的机器上运行良好:

gst-launch-1.0 --quiet rtspsrc location=rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4, queue2, rtph264depay, capsfilter caps="video/x-h264, width=240, height=160" ! avdec_h264 ! videoconvert ! capsfilter caps="video/x-raw, format=BGR" ! fdsink | ffplay -f rawvideo -pixel_format rgb24 -video_size 240x160 -i -


It also works without capsfilter caps="video/x-h264, width=240, height=160" :它也可以在没有capsfilter caps="video/x-h264, width=240, height=160"情况下工作:

gst-launch-1.0 --quiet rtspsrc location=rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4, queue2 ! rtph264depay ! avdec_h264 ! videoconvert ! capsfilter caps="video/x-raw, format=BGR" ! fdsink | ffplay -f rawvideo -pixel_format rgb24 -video_size 240x160 -i -

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM