Reputation: 5055
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?
Upvotes: 0
Views: 1373
Reputation: 21
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.
Upvotes: 1