2

I have 8 sound cards installed and am trying to create dos code to dummy echo all the sound card exact names to text file. But ffmpeg won't echo output to a file .

Here is what I have tried, and not doing what it is supposed to do:

ffmpeg -list_devices true -f dshow -i dummy>>SoundCardName%batnum%.txt

it just lists.

Also, this doesn't work, and only lists the first sound card:

@For /f tokens^=1^,2delims^=^" %%a in (
'ffmpeg -list_devices true -f dshow -i dummy 2^>^&1 ^| findstr /c:"audio"'
) do (
   if not defined AudioDevice (
      set "AudioDevice=%%~b"
      Echo "%AudioDevice%">>SoundCardName%batnum%.txt

) )

I need all 8 sound cards listed.

I don't know what 2^>^&1 means.

I don't know what | findstr /c:"audio"' does. I always see pipe as something that should be or, but more likely is piping to something, in this case, I don't know.

Anyway. Why cant I simply >> the output to a file, that is shown in the dos box?

DavidPostill
  • 162,382
degarb
  • 31

1 Answers1

0
@echo off & cd /d "%~dp0"

set "_cnt=1"
set "_ffmpeg=C:\Program Files\ffmepg\bin\ffmpeg.exe"
set "_arg=-hide_banner -list_devices true -f dshow -i dummy"

for /l %%L in (01,01,0%_cnt%)do if defined _AuDev_%%~L 1>nul =;(
     set "_AuDev_%%~L=" & del /q /f /a "AuDev_%%~L.txt" 2>&1 );=

for /f usebacktokens^=2delims^=^" %%i in (`^<con: 2^>^&1 ^<nul ^
     "%_ffmpeg%" %_arg% ^| %__AppDir__%findstr.exe /e .*audio^)`
     )do call set "_AuDev_%%_cnt%%=%%~i" & call set /a "_cnt+=1"

  • Or, if you want to list filename and content at runtime:
@echo off & cd /d "%~dp0"

set "_cnt=1" set "_ffmpeg=C:\Program Files\ffmepg\bin\ffmpeg.exe" set "_arg=-hide_banner -list_devices true -f dshow -i dummy"

for /l %%L in (01,01,0%cnt%)do if defined _AuDev%%~L 1>nul =;( set "AuDev%%~L=" & del /q /f /a "AuDev_%%~L.txt" 2>&1 );=

for /f usebacktokens^=2delims^=^" %%i in (^&lt;con: 2^&gt;^&amp;1 ^&lt;nul ^ &quot;%_ffmpeg%&quot; %_arg% ^| %__AppDir__%findstr.exe /e .*audio^) )do call set "AuDev%%_cnt%%=%%~i" & call set /a "_cnt+=1"

for /l %%L in (01,01,0%cnt%)do @if defined _AuDev%%~L 2>&1 =;( %ComSpec% /v /c "echo!AuDev%%~L!>.&quot;AuDev_%%~L.txt"" );=

for /f useback^tokens^=delims^= %%i in (`dir /b /on AuDev_.txt `)do cd.| set /p "'=File: .%%~nxi # Device: " & type "%%~i"

  • Outputs:
File: .\AuDev_1.txt # Device: Microfone (Conexant SmartAudio HD)
File: .\AuDev_2.txt # Device: CABLE Output (VB-Audio Virtual Cable)

Some further reading:

Io-oI
  • 9,237