Reliable audio capture method on windows ? (stereo mix does not exist on most computers)
Hi, I need a way to capture output audio that works reliably on most computers without having to know anything about the state of said computer. Searching for ffmpeg how to capture desktop audio only returns variants of -f dshow -i audio="Stereo Mix (Realtek High Definition Audio)" However, none of the computers I have in the house have any form of "stereo mix" recording device Yes,I did try all of these fixes https://www.wintips.org/how-to-enable-stereo-mix-if-not-showing-as-recording... https://www.hitechwork.com/how-to-restore-missing-stereo-mix-on-windows-10/ https://answers.microsoft.com/en-us/windows/forum/all/stereo-mix-missing-in-... https://answers.microsoft.com/en-us/windows/forum/all/stereo-mix-not-showing... https://thedroidguy.com/how-to-restore-missing-stereo-mix-on-windows-10-1147... https://appuals.com/how-to-restore-missing-stereo-mix-on-windows-10/ None of them work, stereo mix is a sound card driver feature that only exists on some cards and only some drivers. Most random computers you come across will not have this so giving the user a ffmpeg command string almost always fails. As far as I can tell, ffmpeg has no current way of desktop audio capture on windows If it existed, I think it would be described here https://ffmpeg.org/ffmpeg-all.html#toc-Audio-Sources ? But audio capture is possible without 3rd party applications or drivers on windows. OBS proves it, it can capture on all of my computers without any prior setting up There seems to be two systems which OBS uses, one that can capture all system output audio and one that can capture audio on a per application basis. I'm not sure what the API is for the whole desktop (presumably an older API), but the for the per-application capture, it is using the ActivateAudioInterfaceAsync <https://docs.microsoft.com/en-us/windows/win32/api/mmdeviceapi/nf-mmdeviceapi-activateaudiointerfaceasync> API, which has been back ported to later versions of windows 10. I have done some poking around in the ffmpeg code and found these clues to how they are doing it. obs forum post by audio capture dev https://obsproject.com/forum/threads/audiosource-sortaudio.11355/#post-63438 audio related obs files https://github.com/obsproject/obs-studio https://github.com/obsproject/obs-studio/blob/master/libobs/media-io/audio-i... https://github.com/obsproject/obs-studio/blob/master/libobs/media-io/audio-i... https://github.com/obsproject/obs-studio/blob/master/libobs/obs-audio.c https://github.com/obsproject/obs-studio/blob/master/libobs/obs-audio-contro... https://github.com/obsproject/obs-studio/blob/master/libobs/audio-monitoring... https://github.com/obsproject/obs-studio/blob/master/plugins/coreaudio-encod... win-capture-audio https://github.com/bozbez/win-capture-audio ActivateAudioInterfaceAsync with AUDIOCLIENT_PROCESS_LOOPBACK_PARAMS https://docs.microsoft.com/en-us/windows/win32/api/mmdeviceapi/nf-mmdeviceap... https://docs.microsoft.com/en-us/windows/win32/api/audioclientactivationpara... https://github.com/bozbez/win-capture-audio/blob/main/src/audio-capture.hpp https://github.com/bozbez/win-capture-audio/blob/main/src/audio-capture.cpp
On 11/7/2022 10:17 PM, Joe Smithy wrote:
I need a way to capture output audio that works reliably on most computers without having to know anything about the state of said computer.
I suspect you won't, at least not directly. If the search is narrowed to specific versions of windoze and dshow, it may get easier. (On a modern win10 thinkpad here w/ OBS, the only audio output captures are the named sound devices - "Speakers (USB PnP Audio device)" and "Speakers (Realtek(R) Audio)". IME most windows capture software uses pick lists to get the desired device. You might be able to script something to simply use the first device, but of course, that might fail on some. z!
On Mon, Nov 7, 2022 at 11:17 PM Joe Smithy <ffmpeg-user@domn.net> wrote:
Hi,
I need a way to capture output audio that works reliably on most computers without having to know anything about the state of said computer.
Searching for ffmpeg how to capture desktop audio only returns variants of
-f dshow -i audio="Stereo Mix (Realtek High Definition Audio)"
However, none of the computers I have in the house have any form of "stereo mix" recording device
Yes,I did try all of these fixes
https://www.wintips.org/how-to-enable-stereo-mix-if-not-showing-as-recording... https://www.hitechwork.com/how-to-restore-missing-stereo-mix-on-windows-10/ https://answers.microsoft.com/en-us/windows/forum/all/stereo-mix-missing-in-... https://answers.microsoft.com/en-us/windows/forum/all/stereo-mix-not-showing... https://thedroidguy.com/how-to-restore-missing-stereo-mix-on-windows-10-1147... https://appuals.com/how-to-restore-missing-stereo-mix-on-windows-10/
None of them work, stereo mix is a sound card driver feature that only exists on some cards and only some drivers. Most random computers you come across will not have this so giving the user a ffmpeg command string almost always fails.
Stereo mix is just the "name" of the sound device. Names will vary. Maybe should make that more clear. You can enumerate them like ffmpeg -list_devices true -f dshow -i dummy Thanks.
participants (3)
-
Carl Zwanzig -
Joe Smithy -
Roger Pack