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

vuott at tutanota.com vuott at tutanota.com
Tue Jan 16 12:22:01 CET 2024


The reason remained a mystery to me as well.

I solved this problem, which occurs when recording audio or even when converting from one audio format to another, through the use of a temporary support file, as can easily be seen on these two pages of the Italian wiki that I wrote.

https://www.gambas-it.org/wiki/index.php/Riproduzione_e_contemporanea_registrazione_dell%27audio_di_radio_WEB_mediante_il_Componente_gb.media

https://www.gambas-it.org/wiki/index.php/Convertire_i_formati_audio_mediante_il_Componente_gb.media



16 gen 2024, 10:44 da claus.dietrich at freenet.de:

>
> 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" <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/a2452fc2/attachment.htm>


More information about the User mailing list