How can I resize the webcam output? I'm using v4l2src...
Thiago Santos
thiagoss at osg.samsung.com
Fri Aug 7 06:49:10 PDT 2015
On 08/06/2015 06:20 PM, Giacomo D wrote:
> Great!!! It works perfectly.
>
> Now I have written a Python file to do the same thing but it doesn't work.
> Is there something that I do wrong?
"Does not work" is not helpful for us to help you. How does it not work?
Any interesting messages on GST_DEBUG log?
Also there are lots of functions in your code with return values that
should be checked to see if the operations succeeded.
Regards,
>
> Thanks
> Giacomo
>
>
>
> __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 OnDynamicPad1 (self, element,pad):
> # pad.link(self.videoformatconverter1.get_static_pad("sink"))
>
> def OnDynamicPad2 (self, element,pad):
> pad.link(self.videoformatconverter2.get_static_pad("sink"))
>
> def OnDynamicPad3 (self, element,pad):
> pad.link(self.videoformatconverter3.get_static_pad("sink"))
>
> def OnDynamicPad4 (self, element,pad):
> pad.link(self.videoformatconverter4.get_static_pad("sink"))
>
> 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.v4l2src = Gst.ElementFactory.make('v4l2src', None)
> self.v4l2src.set_property("device", "/dev/video0")
> #self.filesrc1.set_property("location",
> "/home/giacomo/Scrivania/Sam_Smith_-_Im_Not_The_Only_One.avi")
> self.pipeline.add(self.v4l2src)
>
>
> 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.decodebin2 = Gst.ElementFactory.make('decodebin', None)
> self.decodebin2.connect("pad-added",self.OnDynamicPad2)
> self.pipeline.add(self.decodebin2)
>
> self.decodebin3 = Gst.ElementFactory.make('decodebin', None)
> self.decodebin3.connect("pad-added",self.OnDynamicPad3)
> self.pipeline.add(self.decodebin3)
>
> self.decodebin4 = Gst.ElementFactory.make('decodebin', None)
> self.decodebin4.connect("pad-added",self.OnDynamicPad4)
> 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,framerate=30/1,pixel-aspect-ratio=1/1")
>
> self.camerafilter1 = Gst.ElementFactory.make("capsfilter", "filter1")
> self.camerafilter1.set_property("caps", camera1caps)
> self.pipeline.add(self.camerafilter1)
>
> camera1biscaps = Gst.Caps.from_string("video/x-raw,framerate=30/1")
>
> self.camerafilter1bis = Gst.ElementFactory.make("capsfilter",
> "filter1bis")
> self.camerafilter1.set_property("caps", camera1biscaps)
> self.pipeline.add(self.camerafilter1bis)
>
>
> camera2caps =
> Gst.Caps.from_string("video/x-raw,width=200,height=100,pixel-aspect-ratio=1/1")
> 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,pixel-aspect-ratio=1/1")
>
> 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,pixel-aspect-ratio=1/1")
>
> 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.v4l2src.link(self.camerafilter1bis)
> self.camerafilter1bis.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)
>
>
>
>
>
>
>
> --
> View this message in context: http://gstreamer-devel.966125.n4.nabble.com/How-can-I-resize-the-webcam-output-I-m-using-v4l2src-tp4673018p4673023.html
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
--
Thiago Sousa Santos
Senior Multimedia Engineer, Open Source Group
Samsung Research America - Silicon Valley
More information about the gstreamer-devel
mailing list