Differenze tra le versioni di "Riprodurre un video ruotato in tempo reale con la funzione esterna ''gst parse launch( )'' di GStreamer"

Da Gambas-it.org - Wikipedia.
 
Riga 3: Riga 3:
 
Consente, duqnue, anche di riprodurre un video ruotandolo in tempo reale secondo l'opzione impostata nella proprietà ''videoflip method'' .
 
Consente, duqnue, anche di riprodurre un video ruotandolo in tempo reale secondo l'opzione impostata nella proprietà ''videoflip method'' .
  
Sarà necessario avere installata nel sistema e richiamare nell'applicazione Gambas la libreria condivisa: "''libgstreamer-1.0'' ".
+
Sarà necessario avere installata nel sistema e richiamare nell'applicazione Gambas la libreria condivisa: "''libgstreamer-1.0.so.0.2403.0'' ".
  
 
Mostriamo un esempio pratico:
 
Mostriamo un esempio pratico:
Riga 9: Riga 9:
 
   
 
   
 
   
 
   
  Library "libgstreamer-1.0"
+
  Library "libgstreamer-1.0:0.2403.0"
 
   
 
   
 
  Private Enum GST_VIDEO_FLIP_METHOD_IDENTITY = 0, GST_VIDEO_FLIP_METHOD_90R, GST_VIDEO_FLIP_METHOD_180,
 
  Private Enum GST_VIDEO_FLIP_METHOD_IDENTITY = 0, GST_VIDEO_FLIP_METHOD_90R, GST_VIDEO_FLIP_METHOD_180,
Riga 44: Riga 44:
 
   gst_init(0, 0)
 
   gst_init(0, 0)
 
      
 
      
   video = gst_parse_launch("filesrc location=<FONT Color=gray>''/percorso/del/file/video''</font> ! decodebin name=decoder decoder. ! audioconvert ! audioresample ! alsasink decoder. ! videoflip method=" & CStr(GST_VIDEO_FLIP_METHOD_90R) & " ! videoconvert ! ximagesink", 0)
+
   video = gst_parse_launch("filesrc location=<FONT Color=darkgreen>''/percorso/del/file/video''</font> ! decodebin name=decoder decoder. ! audioconvert ! audioresample ! alsasink decoder. ! videoflip method=" & CStr(GST_VIDEO_FLIP_METHOD_90R) & " ! videoconvert ! ximagesink", 0)
 
              
 
              
 
  <FONT Color=gray>' ''Avviamo la riproduzione video:''</font>
 
  <FONT Color=gray>' ''Avviamo la riproduzione video:''</font>

Versione attuale delle 16:28, 4 lug 2024

La funzione esterna "gst_parse_launch()" della libreria GStreamer consente di costruire e gestire in modo semplice una pipeline GStreamer. La riga della pipeline gestita dalla funzione esterna "gst_parse_launch()" è un insieme di elementi separati da punti esclamativi (!). Le proprietà possono essere aggiunte agli elementi, sotto forma di: proprietà = valore.

Consente, duqnue, anche di riprodurre un video ruotandolo in tempo reale secondo l'opzione impostata nella proprietà videoflip method .

Sarà necessario avere installata nel sistema e richiamare nell'applicazione Gambas la libreria condivisa: "libgstreamer-1.0.so.0.2403.0 ".

Mostriamo un esempio pratico:

Private video As Pointer


Library "libgstreamer-1.0:0.2403.0"

Private Enum GST_VIDEO_FLIP_METHOD_IDENTITY = 0, GST_VIDEO_FLIP_METHOD_90R, GST_VIDEO_FLIP_METHOD_180,
             GST_VIDEO_FLIP_METHOD_90L, GST_VIDEO_FLIP_METHOD_HORIZ, GST_VIDEO_FLIP_METHOD_VERT,
             GST_VIDEO_FLIP_METHOD_TRANS, GST_VIDEO_FLIP_METHOD_OTHER, GST_VIDEO_FLIP_METHOD_AUTO
Private Enum GST_STATE_VOID_PENDING = 0, GST_STATE_NULL, GST_STATE_READY, GST_STATE_PAUSED, GST_STATE_PLAYING
Private Const GST_FORMAT_TIME As Integer = 3

' gst_init (int *argc, char **argv[])
' Initializes the GStreamer library, setting up internal path lists, registering built-in elements, and loading standard plugins.
Private Extern gst_init(argc As Pointer, argv As Pointer)

' GstElement * gst_parse_launch (const gchar *pipeline_description, GError **error)
' Create a new pipeline based on command line syntax.
Private Extern gst_parse_launch(description As String, GError As Pointer) As Pointer

' GstStateChangeReturn gst_element_set_state(GstElement *element, GstState state)
' Sets the state of the element.
Private Extern gst_element_set_state(gstelement As Pointer, state As Integer) As Integer
 
' gboolean gst_element_query_position (GstElement *element, GstFormat format, gint64 *cur)
' Queries an element for the stream position in nanoseconds.
Private Extern gst_element_query_position(gstelement As Pointer, gstformat As Pointer, cur As Pointer) As Boolean

' void gst_object_unref(gpointer object)
' Decrements the reference count on object.
Private Extern gst_object_unref(gobject As Pointer)


Public Sub Main()
  
 Dim tempus As Long

 gst_init(0, 0)
   
 video = gst_parse_launch("filesrc location=/percorso/del/file/video ! decodebin name=decoder decoder. ! audioconvert ! audioresample ! alsasink decoder. ! videoflip method=" & CStr(GST_VIDEO_FLIP_METHOD_90R) & " ! videoconvert ! ximagesink", 0)
           
' Avviamo la riproduzione video:
 gst_element_set_state(video, GST_STATE_PLAYING)
   
 Do
   gst_element_query_position(video, GST_FORMAT_TIME, VarPtr(tempus))
   Write "\rTempo: " & Time(0, 0, 0, tempus / 1000000)
   Flush
   Wait 0.01
 Loop
  
End


Public Sub Application_Read()

 Dim s As String

' Resta in attesa che sia premuto uno dei seguenti tasti della tastiera
 Input #File.In, s 
  
 Select Case s
   Case "p"
' Pone in pausa la riproduzione del file mediale
     gst_element_set_state(video, GST_STATE_PAUSED)
   Case "r"
' Riprende la riproduzione del file mediale
     gst_element_set_state(video, GST_STATE_PLAYING)
   Case "s"
' Arresta la riproduzione del file mediale
     gst_element_set_state(video, GST_STATE_NULL)
     gst_object_unref(video)
     Print "\nEsecuzione terminata."
     Quit
 End Select

End


Riferimenti