[Gambas-user] Shell comand + FFMPEG from gambas how to
Claus Dietrich
claus.dietrich at freenet.de
Sat Oct 21 21:33:36 CEST 2023
Hi Martin
I had the same issue with parallel ffmpeg processes and finally decided
to use native Gambas means (= GStreamer resources) for audio recording.
I quickly put a class together for you with a little demo app which allows
- to choose the recording format (mp3, ogg or wav)
- to record from an alsa-device or to record a web audio stream (URL)
- to select an alsa-device (i.e. mike or monitor)
- to return a list of available alsa-devices as string-array
- to select the output directory (default=user home directory) where the
audio file shall be saved as yyyy-mm-dd-hh-nn-ss_rec.<format>
With this class it should be possible to record the mike and monitor in
parallel by using 2 instances. I tested the parallel recording of a web
radio station stream and the mike of my Webcam.
If you didn't receive the demo project with this mail you can download
it from my cloud: https://magentacloud.de/s/w45JHPTW7KJEwke
Hope that it works on your platform and that you can use it.
Regards
Claus
Am 20.10.23 um 23:44 schrieb Martín:
> 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.
>
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Audio_Recording_MediaControl_0.0.4.tar.gz
Type: application/gzip
Size: 17953 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20231021/1cca2b84/attachment-0001.gz>
More information about the User
mailing list