Is it possible to do appsrc--ximagesink setup in Gstreamer

你离开我真会死。 提交于 2019-12-10 00:44:39

问题


I want to stream some random bytes to Gstreamer and display it as follows:

[Rand Bytes]--[Video source=appsrc]--[Video sink=ximagesink]

The following Python code I found in this SO post works

source = gst.element_factory_make("appsrc", "source")
caps = gst.Caps("video/x-raw-gray,bpp=16,endianness=1234,width=320,height=240,framerate=(fraction)10/1")
source.set_property('caps',caps)
source.set_property('blocksize',320*240*2)
source.connect('need-data', self.genRandBytes)

colorspace = gst.element_factory_make('ffmpegcolorspace') #To remove

videosink = gst.element_factory_make('ximagesink')
caps = gst.Caps("video/x-raw-yuv,width=320,height=240,framerate=(fraction)10/1,format=(fourcc)I420")
videosink.caps = caps

gst.element_link_many(source, colorspace, videosink)

However if I remove the colorspace part and set videosink.caps as the same as source's, it stops working(nothing happens after clicking start).

My question is why is colorspace needed here? Is it possible to do just appsrc--ximagesink setup?


回答1:


ximagesink doesn't support x-raw-gray, hence the need for colorspace conversion.

Having said that, the documentation says that ximagesink only supports video/x-raw-rgb, so I'm thinking that setting that caps property on the sink isn't doing much. In fact, looking at the output of the sink pad on ximagesource's get_caps() method, it's still video/x-raw-rgb even after that caps property is set and playback has started. Taking out the line setting the caps property has no effect on the output.

http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-plugins/html/gst-plugins-base-plugins-ximagesink.html



来源:https://stackoverflow.com/questions/8174898/is-it-possible-to-do-appsrc-ximagesink-setup-in-gstreamer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!