B4J Question How to read the name of the 'audio channel' corresponding to the PC sound card output?

amorosik

Expert
Licensed User
I would like to obtain from the code the reading of the name of the audio channel corresponding to the output of the PC sound card
For those interested in PC video and audio recording, see this post
The audio channel name which will then be used in the code described below

B4X:
            Dim par As List
            par.Initialize
            par.Add("-f")
            par.Add("gdigrab")
            par.Add("-framerate")
            par.Add("25")
            If width1>100 And height1>100 Then
                par.Add("-offset_x")
                par.Add(left1.As(String))
                par.Add("-offset_y")
                par.Add(top1.As(String))
                par.Add("-video_size")
                par.Add(width1.As(String) & "x" & height1.As(String))
                'par.Add("-show_region")
                'par.Add("1")
            End If
            par.Add("-i")
            par.Add("desktop")
            par.Add("-f")        'May be dshow
            par.Add("dshow")    'not working at your PC - remove these two lines...
            par.Add("-vcodec")
            par.Add("libx264")
            'par.Add("-movflags")
            'par.Add("empty_moov")

            par.Add("-f")        'add audio source
            par.Add("dshow")
-->>        par.Add("audio=" & quote & "Stereo-Mix" & quote )  'Not sure if at your pc is Stereo-Mix or something different... this always changes from language/region settings

            par.Add("-f")
            par.Add("mp4")
            par.Add(QUOTE & CaptureFolder & "\" & CaptureFileName & QUOTE) 'at pipe... or - ??? hmmm
            arun("ffmpeg.exe",par)

So the question is: how to read, from the B4J code, the name of the audio channel corresponding to the PC's sound card output?
 

Vitor

Member
I would like to obtain from the code the reading of the name of the audio channel corresponding to the output of the PC sound card
For those interested in PC video and audio recording, see this post
The audio channel name which will then be used in the code described below

B4X:
            Dim par As List
            par.Initialize
            par.Add("-f")
            par.Add("gdigrab")
            par.Add("-framerate")
            par.Add("25")
            If width1>100 And height1>100 Then
                par.Add("-offset_x")
                par.Add(left1.As(String))
                par.Add("-offset_y")
                par.Add(top1.As(String))
                par.Add("-video_size")
                par.Add(width1.As(String) & "x" & height1.As(String))
                'par.Add("-show_region")
                'par.Add("1")
            End If
            par.Add("-i")
            par.Add("desktop")
            par.Add("-f")        'May be dshow
            par.Add("dshow")    'not working at your PC - remove these two lines...
            par.Add("-vcodec")
            par.Add("libx264")
            'par.Add("-movflags")
            'par.Add("empty_moov")

            par.Add("-f")        'add audio source
            par.Add("dshow")
-->>        par.Add("audio=" & quote & "Stereo-Mix" & quote )  'Not sure if at your pc is Stereo-Mix or something different... this always changes from language/region settings

            par.Add("-f")
            par.Add("mp4")
            par.Add(QUOTE & CaptureFolder & "\" & CaptureFileName & QUOTE) 'at pipe... or - ??? hmmm
            arun("ffmpeg.exe",par)

So the question is: how to read, from the B4J code, the name of the audio channel corresponding to the PC's sound card output?
Try use this command
c:\\ffmpeg\\bin\ffmpeg -list_devices true -f dshow -i dummy
 
Upvote 0

MicroDrie

Well-Known Member
Licensed User
Longtime User
The following code will print the name and description of each available mixer to the log. You can look for the mixer that corresponds to your audio card based on its name.

B4J In-Line Java solution:
    Dim MyJO As JavaObject = Me
    MyJO.RunMethod("AudioCardInfo",Array(Null))

    #if JAVA
        import javax.sound.sampled.AudioSystem;
        import javax.sound.sampled.Mixer;

        public void AudioCardInfo(String[] args) {
            Mixer.Info[] mixerInfos = AudioSystem.getMixerInfo();
            int i = 0;
            for (Mixer.Info info : mixerInfos) {
                System.out.println(i + " Name : " + info.getName());
                System.out.println(i + " Description: " + info.getDescription());
                System.out.println(i + " Version: " + info.getVersion());
                System.out.println(i + " Vendor : " + info.getVendor());
                System.out.println("---");
                i++;
            }
        }
    #End If

The result:
0 Name : Primair geluidsstuurprogramma
0 Description: Direct Audio Device: DirectSound Playback
0 Version: Unknown Version
0 Vendor : Unknown Vendor
---
1 Name : Speaker (Realtek(R) Audio)
1 Description: Direct Audio Device: DirectSound Playback
1 Version: Unknown Version
1 Vendor : Unknown Vendor
---
2 Name : Primair stuurprogramma voor opnemen van geluid
2 Description: Direct Audio Device: DirectSound Capture
2 Version: Unknown Version
2 Vendor : Unknown Vendor
---
3 Name : Microfoonmatrix (Intel® Smart
3 Description: Direct Audio Device: DirectSound Capture
3 Version: Unknown Version
3 Vendor : Unknown Vendor
---
4 Name : Port Speaker (Realtek(R) Audio)
4 Description: Port Mixer
4 Version: 10.0
4 Vendor : Unknown Vendor
---
5 Name : Port Microfoonmatrix (Intel® Smart
5 Description: Port Mixer
5 Version: 10.0
5 Vendor : Unknown Vendor
---
 
Upvote 0
Top