Opened 5 years ago

Last modified 3 months ago

#9408 new enhancement

WASAPI Audio Input/Output Support

Reported by: Brad Isbell Owned by:
Priority: wish Component: avdevice
Version: git-master Keywords:
Cc: Brad Isbell Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

The Windows Audio Session API (WASAPI) is a modern API for audio playback/capture under Windows. It offers several benefits over the current DirectShow implementation in FFmpeg:

Sample Usage

Capture from multichannel soundcard:

ffmpeg -f wasapi -ar 96000 -ac 8 -i device="My Multichannel Soundcard" …

Capture in exclusive mode from soundcard named 'Soundcard':

ffmpeg -f wasapi -exclusive_mode true -i device="Soundcard" …

Capture loopback from soundcard named 'Soundcard':

ffmpeg -f wasapi -i loopback_device="Soundcard" …

Capture loopback from entire system:

ffmpeg -f wasapi -i loopback_system=true …

Capture loopback from app by name or PID:

ffmpeg -f wasapi -i loopback_application_pid=54321 …
ffmpeg -f wasapi -i loopback_application_name="Skifree" …

Change History (7)

comment:1 by Balling, 5 years ago

SDL_OpenAudio ffplay already uses WASAPI. Interesting that 8.1 is apparently not supported.

comment:2 by Carl Eugen Hoyos, 4 years ago

Component: undetermined → avdevice
Priority: normal → wish
Version: unspecified → git-master

comment:3 by Glenn C Newell, 20 months ago

This is a problem in that modern immersive surround formats have more than 8 channels, not to mention High Order Ambisonics. Other aspects of ffmpeg have channel support up to 22.2, but for playback SDL2 is a bottleneck.

A Related note, even given dshow and WASAPI support, it is very difficult/impossible to find windows binary builds with support for those.

comment:4 by Brad Isbell, 20 months ago

Another use case that's popped up is capturing in 32-bit float. Several prosumer audio interfaces and recorders now support floating point audio capture. 32-bit float can be captured with WASAPI. Samples with values >±1.0 can be captured with WASAPI in exclusive mode. Gstreamer supports this today. If FFmpeg adds support, that goes a long way to enabling floating point capture in all the applications built on FFmpeg.

comment:5 by Federico Gratti, 17 months ago

It would be great to have WASAPI on ffmpeg. Mainly to capture loopback from entire system and use it with the Screen Recording feature

comment:6 by Juan Domingo, 17 months ago

ヽ༼ຈل͜ຈ༽ノ currently requesting for WASAPI ヽ༼ຈل͜ຈ༽ノ I need it for ... a private project lol

comment:7 by Tomáš Mariančík, 3 months ago

This would be hugely helpful for streaming applications, especially if the capture with application PID is supported too.

FFmpeg already supports capturing desktop and individual applications on Windows, but currently there is no easy way to capture their audio as well.

I'm currently working on screen sharing functionality with FFmpeg for a social VR app and this would greatly simplify the process.


I would also suggest adding support for capturing everything but the given application PID - this allows whole desktop capture while excluding specific app (so it doesn't capture its own output).

The Application Loopback Capture has support for this: ​https://github.com/microsoft/windows-classic-samples/tree/main/Samples/ApplicationLoopback

However I'm unsure if this would be part of this filter or separate, because I don't think it falls under WASAPI? However the initial post mentions capturing with PID, so I thought to include this.

Last edited 3 months ago by Tomáš Mariančík (previous) (diff)
Note: See TracTickets for help on using tickets.