[Gambas-user] gb.media - audio recording file is emptied when ending the program

Claus Dietrich claus.dietrich at freenet.de
Tue Jan 16 10:43:33 CET 2024


I drafted the following snippet project for the Gambas-Buch which shall 
demonstrate the use of a GStreamer TEE element. It plays a web radio 
station which can be heard via the speaker and is recorded in a file. 
When I start the program everything seems to be fine but when I end the 
program the mp3 file is emptied (0 bytes). Why does this happen and how 
can this be prevented?

Best regards

Claus

     Private pl As MediaPipeline
     'Declarations for source
     Private src As MediaControl
     Private tee As MediaControl
     Private cnv As MediaControl
     'Declarations for branch 1
     Private que1 As MediaControl
     Private snk1 As MediaControl
     'Declarations for branch 2
     Private que2 As MediaControl
     Private enc2 As MediaControl
     Private snk2 As MediaControl

Public Sub Form_Open()

     pl = New MediaPipeline
     'Source
     src = New MediaControl(pl, "uridecodebin")
     src["uri"] = 
"http://icecast.ndr.de/ndr/ndrinfo/schleswigholstein/mp3/128/stream.mp3"
     cnv = New MediaControl(pl, "audioconvert")
     tee = New MediaControl(pl, "tee")
     'Branch 1
     que1 = New MediaControl(pl, "queue")
     snk1 = New MediaControl(pl, "autoaudiosink")
     'Branch 2
     que2 = New MediaControl(pl, "queue")
     enc2 = New MediaControl(pl, "lamemp3enc")
     enc2["target"] = "bitrate"
     enc2["bitrate"] = 128
     enc2["cbr"] = True
     snk2 = New MediaControl(pl, "filesink")
     snk2["location"] = "/home/" & System.User.Name & "/radio_rec.mp3"

     'Link source elements
     src.LinkLaterTo(cnv)
     cnv.LinkTo(tee)
     'Link to TEE and link branch 1 elements
     tee.LinkTo(que1)
     que1.LinkTo(snk1)
     'Link to TEE and link branch 2 elements
     tee.LinkTo(que2)
     que2.LinkTo(enc2)
     enc2.LinkTo(snk2)

     pl.play

End

Public Sub Form_Close()

   pl.Stop
   pl.close

End
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20240116/14e458f0/attachment.htm>


More information about the User mailing list