[Gambas-user] gb.media - audio recording file is emptied when ending the program
vuott at tutanota.com
vuott at tutanota.com
Tue Jan 16 16:27:18 CET 2024
Hello Claus,
I suppose only Minisini can solve this question.
Considering the pipeline you mentioned, you could in the meantime use external GStreamer functions in Gambas, ......but I don't think that's what you want. :-D
Private bo As Boolean
Library "libgstreamer-1.0"
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
<FONT Color=gray>' ''gst_init (int *argc, char **argv[])''
' ''Initializes the GStreamer library, setting up internal path lists, registering built-in elements, and loading standard plugins.''</font>
Private Extern gst_init(argc As Pointer, argv As Pointer)
<FONT Color=gray>' ''GstElement * gst_parse_launch (const gchar *pipeline_description, GError **error)''
' ''Create a new pipeline based on command line syntax.''</font>
Private Extern gst_parse_launch(description As String, GError As Pointer) As Pointer
<FONT Color=gray>' ''GstStateChangeReturn gst_element_set_state(GstElement *element, GstState state)''
' ''Sets the state of the element.''</font>
Private Extern gst_element_set_state(gstelement As Pointer, state As Integer) As Integer
<FONT Color=gray>' ''gboolean gst_element_query_position (GstElement *element, GstFormat format, gint64 *cur)''
' ''Queries an element for the stream position in nanoseconds.''</font>
Private Extern gst_element_query_position(gstelement As Pointer, gstformat As Pointer, cur As Pointer) As Boolean
<FONT Color=gray>' ''void gst_object_unref(gpointer object)''
' ''Decrements the reference count on object.''</font>
Private Extern gst_object_unref(gobject As Pointer)
Public Sub Main()
Dim audio As Pointer
Dim tempus As Long
gst_init(0, 0)
audio = gst_parse_launch("gst-launch-1.0 uridecodebin uri=http://icecast.ndr.de/ndr/ndrinfo/schleswigholstein/mp3/128/stream.mp3 ! audioconvert ! tee name=radio ! queue ! autoaudiosink radio. ! queue ! lamemp3enc target=bitrate bitrate=128 cbr=true ! filesink location=/tmp/output.mp3", 0)
gst_element_set_state(audio, GST_STATE_PLAYING)
While Not bo
gst_element_query_position(audio, GST_FORMAT_TIME, VarPtr(tempus))
Write "\rTimelapsed: " & Str(Time(0, 0, 0, tempus / 1000000)) ' Ruit hora !
Flush
Wait 0.01
Wend
<FONT Color=gray>' ''Stop recording MP3 file:''</font>
gst_element_set_state(audio, GST_STATE_NULL)
gst_object_unref(audio)
Print "\nRecording completed."
Quit
End
Public Sub Application_Read() ' By clicking the "Enter" key on your keyboard, you stop the recording
bo = True
End
16 gen 2024, 15:11 da claus.dietrich at freenet.de:
> Am 16.01.24 um 12:22 schrieb vuott--- via User:
>
>>
>> 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
>>
>
> When I use an according GStreamer CLI-command and end the process with Ctrl-C the mp3 file is not emptied:
>
>
>
>
>
> gst-launch-1.0 uridecodebinuri=> "http://icecast.ndr.de/ndr/ndrinfo/schleswigholstein/mp3/128/stream.mp3" <http://icecast.ndr.de/ndr/ndrinfo/schleswigholstein/mp3/128/stream.mp3>> ! audioconvert ! tee name=radio ! queue ! autoaudiosink radio. ! queue ! lamemp3enc target=bitrate bitrate=128 cbr=true ! filesink location="/home/claus/output.mp3
>
>
> Before using workarounds I wanted to ask, whether there are standard means to accomplish the same in Gambas.
>
>
> Best regards
>
>
> Claus
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20240116/451095d0/attachment-0001.htm>
More information about the User
mailing list