mediaview capture

Post

Posted
Rating:
#1 (In Topic #817)
Avatar
Enthusiast
sadams54 is in the usergroup ‘Enthusiast’
 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?
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Guru
cogier is in the usergroup ‘Guru’
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.
Online now: No Back to the top

Post

Posted
Rating:
#3
Guru
BruceSteers is in the usergroup ‘Guru’
 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.
Online now: No Back to the top

Post

Posted
Rating:
#4
Regular
vuott is in the usergroup ‘Regular’
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.

Code (gambas)

  1. Event Evento
  2.  
  3. Public Sub Form_Open()
  4.  
  5.   Me.Show
  6.   Wait 0.1
  7.  
  8.   MediaView1.URL = "/path/of/media/we/want/to/capture"
  9.  
  10.   Repeat
  11.      Wait 0.01
  12.   Until MediaView1.Position > 0.0
  13.  
  14.   Raise Evento
  15.  
  16.  
  17. Public Sub Form_Evento()
  18.  
  19.   Dim ob As Object
  20.   Dim pn1, pn2 As Panel
  21.   Dim DrawingArea1 As DrawingArea
  22.   Dim pl As MediaPipeline
  23.   Dim src, cnv, enc, mux, snk As MediaControl
  24.  
  25. ' ...the happy "MediaView" family:
  26.   ob = MediaView1.Children[0]
  27.   pn1 = ob.Children[0]
  28.   pn2 = pn1.Children[0]
  29.   DrawingArea1 = pn2.Children[0]
  30.  
  31.   pl = New MediaPipeline
  32.  
  33.   src = New MediaControl(pl, "ximagesrc")
  34. ' Assign to the property "xid" the "DrawingArea" identification number:
  35.   src["xid"] = DrawingArea1.Id
  36.   cnv = New MediaControl(pl, "videoconvert")
  37.   enc = New MediaControl(pl, "x264enc")
  38.   mux = New MediaControl(pl, "matroskamux")
  39.   snk = New MediaControl(pl, "filesink")
  40. ' Set the path of final video file of mkv format (Matroska):
  41.   snk["location"] = "/tmp/file.mkv"
  42.  
  43. ' Link the "GStreamer" plugins:
  44.   src.LinkTo(cnv)
  45.   cnv.LinkTo(enc)
  46.   enc.LinkTo(mux)
  47.   mux.LinkTo(snk)
  48.  
  49.   pl.play
  50.  
  51.   Wait MediaView1.Duration
  52.  
  53.   Print "Video file created"
  54.  

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Enthusiast
sadams54 is in the usergroup ‘Enthusiast’
 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.
Online now: No Back to the top

Post

Posted
Rating:
#6
Regular
GrantXTV is in the usergroup ‘Regular’
 Hi,

I am trying to go the other way and can't seem find a way to stream out of mediaview, here what I have been working on:

Public bo As Boolean

Public Sub Form_Open()
 bo = True
End

Public Sub send_Click()
 Dim pl As MediaPipeline
 Dim src, aco, wen, snk, rtp, udp As MediaControl
 Dim flt As MediaFilter
 pl = New MediaPipeline
 src = New MediaControl(pl, "alsasrc")   
 aco = New MediaControl(pl, "audioconvert")
 flt = New MediaFilter(pl, "audio/x-raw,rate=44100,depth=16,channels=2,width=16,signed=true")
 rtp = New MediaControl(pl, "rtpL24pay")
 udp = New MediaControl(pl, "udpsink host=192.168.3.15 port=5001")
 src.LinkTo(aco)
 aco.LinkTo(flt)
 flt.LinkTo(rtp)
 rtp.LinkTo(udp)
 pl.Play()
 While bo
   TextBox1.Text = Str(Time(0, 0, 0, pl.Position * 1000))
   Wait 0.01
 Wend
 pl.Stop()
 pl.Close()
 Quit
End

Public Sub stop_Click()
  bo = False
End

Public Sub Form_Close()
  bo = False
End

This is what I tested on gstreamer and it works:
'gst-launch-1.0 alsasrc ! audioconvert ! audio/x-raw,rate=48000,depth=8,channels=2,width=16 ! rtpL24pay ! udpsink host=192.168.3.15 port=5001

What is best way to do this using mediaview, as I have not found a way to get this to work?
Online now: No Back to the top

Post

Posted
Rating:
#7
Regular
vuott is in the usergroup ‘Regular’

GrantXTV said

 udp = New MediaControl(pl, "udpsink host=192.168.3.15 port=5001")
"HOST" and "PORT" are properties of the "udpsink " GStreamer Plugin.
Therefore they should be highlighted and separated.
……
udp = New MediaControl(pl, "udpsink")
udp["host"] = "192.168.3.15"
udp["port"] = 5001
……


GrantXTV said

This is what I tested on gstreamer and it works:
'gst-launch-1.0 alsasrc ! audioconvert ! audio/x-raw,rate=48000,depth=8,channels=2,width=16 ! rtpL24pay ! udpsink host=192.168.3.15 port=5001

What is best way to do this using mediaview, as I have not found a way to get this to work?
If you want to use "gst-launch-1.0 ", you will have to use its corresponding external function "gst_parse_launch()", since it has not been implemented in the Gambas gb.media Component.

Exemplum:
https://www.gambas-it.org/wiki/index.php/Eseguire_un_file_audio_usando_una_linea_di_pipeline_con_la_funzione_%27gst_parse_launch()%27

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top
1 guest and 0 members have just viewed this.