[Gambas-user] Shell comand + FFMPEG from gambas how to

Benoît Minisini benoit.minisini at gambas-basic.org
Sat Oct 21 23:18:24 CEST 2023


Le 20/10/2023 à 23:44, Martín a écrit :
> Hi,
> 
> If I do this in the terminal it works:
> 
> ffmpeg -f pulse -i alsa_output.BLABLABLA.analog-stereo.monitor -i 
> <(arecord -f CD) -filter_complex amix -acodec libmp3lame output.mp3
> 
> But if I do the same although Shell inside the gamabs code it doesn't work.
> 
> What I'm doing wrong? here is the sample code. The idea behind is record 
> 2 audio tracks at the same time one for the micro and other for the 
> internal audio output.
> 
> Private hMicro As Process
> Private hSystem As Process
> 
> Public Sub bRecord_Click()
> 
>    If bRecord.Value Then
>      Record()
>    Else
>      Try hMicro.Kill
>      Try hSystem.Kill
>    Endif
> 
> End
> 
> Private Sub Record()
> 
>    Dim sBase As String
>    Dim sMicro As String
>    Dim sSystem As String
> 
>    sBase = Format(Now(), "yyyy_mm_dd_hhnnss")
>    sMicro = "ffmpeg -f pulse -i alsa_input.BLABLABLA.analog-stereo 
> -acodec libmp3lame " & sBase & "_micro.mp3"
>    sSystem = "ffmpeg -f pulse -i 
> alsa_output.BLABLABLA.analog-stereo.monitor -i <(arecord -f CD) 
> -filter_complex amix -acodec libmp3lame " & sBase & "_system.mp3"
> 
>    hMicro = Shell sMicro For Read As "RMicro"
>    hSystem = Shell sSystem For Read As "RSystem"
> 
> End
> 
> I was thinking to sent the Shell command in a direct way, without start 
> a process first, but how I can kill the process, in the good way, later? 
> Actually I use "killall ffmpeg"
> 
> Second point: it is possible sent 2 commands with ffmpeg? because I sent 
> the first one and then the second one never occur.
> 

I guess 'ffmpeg' expects to be run inside a terminal, so you must 
replace "For Read" by "For Input" in your Shell command to get that.

Moreover, if you don't add the "Wait" keyword, the Shell commands are 
both run at the same time in the background.

Have you read the documentation of the "Shell" instruction?

-- 
Benoît Minisini.



More information about the User mailing list