How create a MediaControl in MediaPipeline?

Ask about the individual Gambas components here.
Post Reply
nino83
Posts: 3
Joined: Monday 4th October 2021 8:34am

How create a MediaControl in MediaPipeline?

Post by nino83 »

Hi, I have this command:

gst-launch-1.0 v4l2src ! videoflip method=rotate-180 ! videoconvert ! ximagesink


How can I create a MediaControl object for the videoflip filter?
vuott
Posts: 262
Joined: Wednesday 5th April 2017 6:07pm
Location: European Union

Re: How create a MediaControl in MediaPipeline?

Post by vuott »

I suggest this code.
(I want to insert an "Enumeration ", so I have to change in the name of some its elements the dash to underscores)
Private Enum none = 0, clockwise, rotate_180, counterclockwise, horizontal_flip,
             vertical_flip, upper_left_diagonal, upper_right_diagonal, automatic
                    
                    
Public Sub Main()
  
  Dim pl As MediaPipeline
  Dim src, flp, cnv, snk As MediaControl
  Dim ftr As MediaFilter
  
  pl = New MediaPipeline 
   
  src = New MediaControl(pl, "v4l2src")
  src["device"] = "/dev/video0"
  ftr = New MediaFilter(pl, "video/x-raw,width=640,height=480,framerate=30/1")
  flp = New MediaControl(pl, "videoflip")
  flp["method"] = rotate_180
  cnv = New MediaControl(pl, "videoconvert")
  snk = New MediaControl(pl, "xvimagesink")
 
' We connect "GStreamer" plugins together:
  src.LinkTo(ftr)
  ftr.LinkTo(flp)
  flp.LinkTo(cnv)
  cnv.LinkTo(snk)
  
' Start video:
  pl.Play()
  
  While True
' The elapsed time from the start of video is shown in console/Terminal:
    Write "\rTempus: " & Time(0, 0, 0, pl.Position * 1000)
    Wait 0.001
  Wend

End
Europaeus sum !

Amare memorentes atque deflentes ad mortem silenter labimur.
nino83
Posts: 3
Joined: Monday 4th October 2021 8:34am

Re: How create a MediaControl in MediaPipeline?

Post by nino83 »

Thanks! it works!
I had tryed a code very very similar, but I didn't use the Enumeration.... I used

flp["method"] = 1

Why in this way it didn't work?

thanks again and bye!
vuott
Posts: 262
Joined: Wednesday 5th April 2017 6:07pm
Location: European Union

Re: How create a MediaControl in MediaPipeline?

Post by vuott »

nino83 wrote: Tuesday 5th October 2021 3:34pm flp["method"] = 1

Why in this way it didn't work?
I do not know. It works for me. :?

Regarding the "Enumeration" resource, obviously this does not affect the functioning of the code.

Ah... more about "video" with "gb.media" Component:
https://www.gambas-it.org/wiki/index.ph ... e_gb.media
Europaeus sum !

Amare memorentes atque deflentes ad mortem silenter labimur.
Post Reply