mediaview capture

Ask about the individual Gambas components here.
Post Reply
sadams54
Posts: 90
Joined: Monday 09th July 2018 3:43am

mediaview capture

Post by sadams54 » Thursday 10th February 2022 8:49pm

I can't find it but is there a way to capture the stream coming in on a mediaview control so it can be saved as a video file?

if it is not possible is there a control that will do this?

User avatar
cogier
Site Admin
Posts: 875
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: mediaview capture

Post by cogier » Thursday 10th February 2022 10:18pm

Have you thought about using Youtube.dl? This can be controlled from within Gambas very easily and is available from the software repository in Ubuntu, Mint etc. and probably other distros as well.

BruceSteers
Posts: 766
Joined: Thursday 23rd July 2020 5:20pm

Re: mediaview capture

Post by BruceSteers » Thursday 10th February 2022 10:19pm

Not easily i should think.

MediaView is limited in what it can do,
you might find something with MediaControl which is the gambas GStreamer interface

You will need to search for if it can be done with GStreamer and if yes then figure out how to get MediaControl to do the same.

vuott
Posts: 112
Joined: Wednesday 05th April 2017 6:07pm
Location: European Union

Re: mediaview capture

Post by vuott » Friday 11th February 2022 5:01am

BruceSteers has correctly suggested to you to use the "MediaControl" Class of the gb.media Component, which however should be used for example in conjunction with the "MediaPipeline" Class.
Well, now I show below a simple code to capture the video - video only, no audio - played in a "MediaView" Control of the gb.media Component. From those capturated data a video file of the "Matroska" format will then be created.
The "MediaView" Control consists of "Children" and "sub-Children" (...grandchildren).
One of these "sub-Children" is a "DrawingArea", which is the Object with which the "MediaView" Control displays images and videos.
We will identify the identification number of this "DrawingArea", constitutive of the "MediaView" Control, and with a particular Property of the "ximagesrc" plugin we will capture the video it shows.
The following code is only illustrative, therefore we will capture only the video data of a video file uploaded and executed by the "MediaView" Control.
Event Evento

Public Sub Form_Open()

  Me.Show
  Wait 0.1

  MediaView1.URL = "/path/of/media/we/want/to/capture"
  
  Repeat 
     Wait 0.01
  Until MediaView1.Position > 0.0
  
  Raise Evento

End

Public Sub Form_Evento()
 
  Dim ob As Object
  Dim pn1, pn2 As Panel
  Dim DrawingArea1 As DrawingArea
  Dim pl As MediaPipeline
  Dim src, cnv, enc, mux, snk As MediaControl
 
' ...the happy "MediaView" family:
  ob = MediaView1.Children[0]
  pn1 = ob.Children[0]
  pn2 = pn1.Children[0]
  DrawingArea1 = pn2.Children[0]
 
  pl = New MediaPipeline 
 
  src = New MediaControl(pl, "ximagesrc")
' Assign to the property "xid" the "DrawingArea" identification number:
  src["xid"] = DrawingArea1.Id
  cnv = New MediaControl(pl, "videoconvert")
  enc = New MediaControl(pl, "x264enc")
  mux = New MediaControl(pl, "matroskamux") 
  snk = New MediaControl(pl, "filesink")
' Set the path of final video file of mkv format (Matroska):
  snk["location"] = "/tmp/file.mkv"
  
' Link the "GStreamer" plugins:
  src.LinkTo(cnv)
  cnv.LinkTo(enc)
  enc.LinkTo(mux)
  mux.LinkTo(snk)
 
  pl.play

  Wait MediaView1.Duration
  
  Print "Video file created"

End
I am a European.

Amare memorentes atque deflentes ad mortem silenter labimur.

sadams54
Posts: 90
Joined: Monday 09th July 2018 3:43am

Re: mediaview capture

Post by sadams54 » Thursday 17th February 2022 7:58pm

I will have to take some time going thru that code you provided. hurts my brain right now.

Let me splain.... I have gotten very pissed off with zoneminder and monitor which are used for security cameras. both are flakey and difficult to keep working. Yes zoneminder especially. I want to write a new app that works simple and reliable. this means monitoring multiple cameras for changes and recording. So please any help in this is appreciated and anybody that is giving answers please give them with this goal in mind.

Post Reply