'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.
The video can be displayed correctly by using the xvimagesink element. 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
Then I use fdsink instead of the xvimagesink element to output the byte stream from the pipeline and play it with 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 -
So is fdsink element wrong or other elements wrong? Thank you for taking the time to help me solve the problem
Solution 1:[1]
There are two issues:
GStreamer writes text messages to
stdout, and FFplay interprets the text as raw pixels.
Add--quietto prevent GStreamer from writing text tostdout.Default GStreamer raw video format is "planar RGB" - red plain then green plane then blue plane.
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":
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 -
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Rotem |


