How can I create a mosaic in Gstreamer? How can I set "sink_0::xpos=0 sink_0::ypos=0 sink_0::alpha=0" in Python?
Giacomo D
omagico.olo at gmail.com
Wed Aug 5 09:26:41 PDT 2015
Perfect Thiago, your help has been great!!
But now everything works fine or it seems so because I haven't got errors
but unfortunately nothing shows.
As I said, I want to write in Python this command line which works well:
gst-launch-1.0 -e \
videomixer name=mix \
sink_0::xpos=0 sink_0::ypos=0 sink_0::alpha=0\
sink_1::xpos=0 sink_1::ypos=0 \
sink_2::xpos=200 sink_2::ypos=0 \
sink_3::xpos=0 sink_3::ypos=100 \
sink_4::xpos=200 sink_4::ypos=100 \
! xvimagesink \
videotestsrc pattern="black" \
! video/x-raw,width=400,height=200 \
! mix.sink_0 \
filesrc location=/home/giacomo/Scrivania/Sam_Smith_-_Im_Not_The_Only_One.avi
\
! decodebin ! videoconvert ! videoscale \
! video/x-raw,width=200,height=100 \
! mix.sink_1 \
filesrc location=/home/giacomo/Scrivania/Sam_Smith_-_Im_Not_The_Only_One.avi
\
! decodebin ! videoconvert ! videoscale \
! video/x-raw,width=200,height=100 \
! mix.sink_2 \
filesrc location=/home/giacomo/Scrivania/Sam_Smith_-_Im_Not_The_Only_One.avi
\
! decodebin ! videoconvert ! videoscale \
! video/x-raw,width=200,height=100 \
! mix.sink_3 \
filesrc location=/home/giacomo/Scrivania/Sam_Smith_-_Im_Not_The_Only_One.avi
\
! decodebin ! videoconvert ! videoscale \
! video/x-raw,width=200,height=100 \
! mix.sink_4 \
and the result is this:
<http://gstreamer-devel.966125.n4.nabble.com/file/n4672994/42.png>
So I have written it in Python like below but nothing is showing up as a
result:
_author__ = 'giacomo'
import sys
from gi.repository import Gst
from gi.repository import GObject
GObject.threads_init()
Gst.init(None)
import os
class VideoBox():
def __init__(self):
mainloop = GObject.MainLoop()
# Create transcoding pipeline
self.pipeline = Gst.Pipeline()
self.videotestsrc = Gst.ElementFactory.make('videotestsrc', None)
self.videotestsrc.set_property("pattern", "black")
self.pipeline.add(self.videotestsrc)
self.filesrc1 = Gst.ElementFactory.make('filesrc', None)
self.filesrc1.set_property("location",
"/home/giacomo/Scrivania/Sam_Smith_-_Im_Not_The_Only_One.avi")
self.pipeline.add(self.filesrc1)
self.filesrc2 = Gst.ElementFactory.make('filesrc', None)
self.filesrc2.set_property("location",
"/home/giacomo/Scrivania/Sam_Smith_-_Im_Not_The_Only_One.avi")
self.pipeline.add(self.filesrc2)
self.filesrc3 = Gst.ElementFactory.make('filesrc', None)
self.filesrc3.set_property("location",
"/home/giacomo/Scrivania/Sam_Smith_-_Im_Not_The_Only_One.avi")
self.pipeline.add(self.filesrc3)
self.filesrc4 = Gst.ElementFactory.make('filesrc', None)
self.filesrc4.set_property("location",
"/home/giacomo/Scrivania/Sam_Smith_-_Im_Not_The_Only_One.avi")
self.pipeline.add(self.filesrc4)
self.videomixer = Gst.ElementFactory.make('videomixer', None)
self.pipeline.add(self.videomixer)
self.pad0 = self.videomixer.get_request_pad("sink_%u")
self.pad1 = self.videomixer.get_request_pad("sink_%u")
self.pad2 = self.videomixer.get_request_pad("sink_%u")
self.pad3 = self.videomixer.get_request_pad("sink_%u")
self.pad4 = self.videomixer.get_request_pad("sink_%u")
#sink_0
self.pad0.set_property('xpos',0)
self.pad0.set_property("ypos",0)
self.pad0.set_property("alpha",0)
#sink_1
self.pad1.set_property("xpos",0)
self.pad1.set_property("ypos",0)
#sink_2
self.pad2.set_property("xpos",200)
self.pad2.set_property("ypos",0)
#sink_3
self.pad3.set_property("xpos",0)
self.pad3.set_property("ypos",100)
#sink_4
self.pad4.set_property("xpos",200)
self.pad4.set_property("ypos",100)
self.decodebin1 = Gst.ElementFactory.make('decodebin', None)
self.pipeline.add(self.decodebin1)
self.decodebin2 = Gst.ElementFactory.make('decodebin', None)
self.pipeline.add(self.decodebin2)
self.decodebin3 = Gst.ElementFactory.make('decodebin', None)
self.pipeline.add(self.decodebin3)
self.decodebin4 = Gst.ElementFactory.make('decodebin', None)
self.pipeline.add(self.decodebin4)
self.videoformatconverter1 = Gst.ElementFactory.make('videoconvert',
None)
self.pipeline.add(self.videoformatconverter1)
self.videoformatconverter2 = Gst.ElementFactory.make('videoconvert',
None)
self.pipeline.add(self.videoformatconverter2)
self.videoformatconverter3 = Gst.ElementFactory.make('videoconvert',
None)
self.pipeline.add(self.videoformatconverter3)
self.videoformatconverter4 = Gst.ElementFactory.make('videoconvert',
None)
self.pipeline.add(self.videoformatconverter4)
self.videoscale1 = Gst.ElementFactory.make('videoscale', None)
self.pipeline.add(self.videoscale1)
self.videoscale2 = Gst.ElementFactory.make('videoscale', None)
self.pipeline.add(self.videoscale2)
self.videoscale3 = Gst.ElementFactory.make('videoscale', None)
self.pipeline.add(self.videoscale3)
self.videoscale4 = Gst.ElementFactory.make('videoscale', None)
self.pipeline.add(self.videoscale4)
camera0caps =
Gst.Caps.from_string("video/x-raw,width=400,height=200")
self.camerafilter0 = Gst.ElementFactory.make("capsfilter", "filter0")
self.camerafilter0.set_property("caps", camera0caps)
self.pipeline.add(self.camerafilter0)
camera1caps =
Gst.Caps.from_string("video/x-raw,width=200,height=100")
self.camerafilter1 = Gst.ElementFactory.make("capsfilter", "filter1")
self.camerafilter1.set_property("caps", camera1caps)
self.pipeline.add(self.camerafilter1)
#
camera2caps =
Gst.Caps.from_string("video/x-raw,width=200,height=100")
self.camerafilter2 = Gst.ElementFactory.make("capsfilter", "filter2")
self.camerafilter2.set_property("caps", camera2caps)
self.pipeline.add(self.camerafilter2)
camera3caps =
Gst.Caps.from_string("video/x-raw,width=200,height=100")
self.camerafilter3 = Gst.ElementFactory.make("capsfilter", "filter3")
self.camerafilter3.set_property("caps", camera3caps)
self.pipeline.add(self.camerafilter3)
camera4caps =
Gst.Caps.from_string("video/x-raw,width=200,height=100")
self.camerafilter4 = Gst.ElementFactory.make("capsfilter", "filter4")
self.camerafilter4.set_property("caps", camera4caps)
self.pipeline.add(self.camerafilter4)
self.xvimagesink = Gst.ElementFactory.make('xvimagesink',None)
self.pipeline.add(self.xvimagesink)
self.videotestsrc.link(self.camerafilter0)
self.camerafilter0.get_static_pad("src").link(self.videomixer.get_static_pad("sink_0"))
self.filesrc1.link(self.decodebin1)
self.decodebin1.link(self.videoformatconverter1)
self.videoformatconverter1.link(self.videoscale1)
self.videoscale1.link(self.camerafilter1)
self.camerafilter1.get_static_pad("src").link(self.videomixer.get_static_pad("sink_1"))
self.filesrc2.link(self.decodebin2)
self.decodebin2.link(self.videoformatconverter2)
self.videoformatconverter2.link(self.videoscale2)
self.videoscale2.link(self.camerafilter2)
self.camerafilter2.get_static_pad("src").link(self.videomixer.get_static_pad("sink_2"))
self.filesrc3.link(self.decodebin3)
self.decodebin3.link(self.videoformatconverter3)
self.videoformatconverter3.link(self.videoscale3)
self.videoscale3.link(self.camerafilter3)
self.camerafilter3.get_static_pad("src").link(self.videomixer.get_static_pad("sink_3"))
self.filesrc4.link(self.decodebin4)
self.decodebin4.link(self.videoformatconverter4)
self.videoformatconverter4.link(self.videoscale4)
self.videoscale4.link(self.camerafilter4)
self.camerafilter4.get_static_pad("src").link(self.videomixer.get_static_pad("sink_4"))
self.videomixer.link(self.xvimagesink)
self.pipeline.set_state(Gst.State.PLAYING)
mainloop.run()
if __name__ == "__main__":
app = VideoBox()
signal.signal(signal.SIGINT, signal.SIG_DFL)
exit_status = app.run(sys.argv)
sys.exit(exit_status)
Can you or someone else help me??
thanks
Giacomo
--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/How-can-I-create-a-mosaic-in-Gstreamer-How-can-I-set-sink-0-xpos-0-sink-0-ypos-0-sink-0-alpha-0-in-P-tp4672943p4672994.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
More information about the gstreamer-devel
mailing list