Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the microphone to be specified when using the 'ffmpeg_microphone' audio pipeline utility function #31820

Open
jrhe opened this issue Jul 6, 2024 · 2 comments
Labels
Audio Feature request Request for a new feature

Comments

@jrhe
Copy link

jrhe commented Jul 6, 2024

Feature request

The 'ffmpeg_microphone' audio pipeline utility function currently doesn't allow the user to specify which microphone to use.

Motivation

ffmpeg_microphone sets a microphone based on the operating system. This microphone may not always be the one the user wants to use, or may be a virtual device created by an application.

I'm using macOS Sonama, where the device defaults to device '0' of type 'avfoundation'. On my machine this corresponds to the 'Microsoft Teams Audio' device where I want to use my Macbook's microphone which is device 1. No idea why Microsoft Teams needs it's own device!

See the following listing from the ffmpeg command:

[...]
[AVFoundation indev @ 0x124e04290] AVFoundation video devices:
[AVFoundation indev @ 0x124e04290] [0] FaceTime HD Camera
[AVFoundation indev @ 0x124e04290] [1] J’s phone Desk View Camera
[AVFoundation indev @ 0x124e04290] [2] Capture screen 0
[AVFoundation indev @ 0x124e04290] AVFoundation audio devices:
[AVFoundation indev @ 0x124e04290] [0] Microsoft Teams Audio
[AVFoundation indev @ 0x124e04290] [1] MacBook Pro Microphone
[AVFoundation indev @ 0x124e04290] [2] J’s phone Microphone
[...]

Your contribution

I'm can submit a PR to add this functionality, but want to get agreement on the function interface changes first.

I'm unsure if it's enough to allow the ffmpeg input device parameter '-i' to be changed, or if the format '-f' parameter might also need to be changed in some cases. I don't think that mac supports anything except AVFoundation so just the input device would be sufficient for my use case. Unsure about Linux and Windows.

Just adding a parameter would be simplest:

    sampling_rate: int,
    chunk_length_s: float,
    format_for_conversion: str = "f32le",
    ffmpeg_input_device: Optional[str] = None,
):```

Alternatively we could allow users to specify arbitrary ffmpeg command line options to override:
```def ffmpeg_microphone(
    sampling_rate: int,
    chunk_length_s: float,
    format_for_conversion: str = "f32le",
    ffmpeg_options: Optional[List[str]] = None,
):```

The function parameters would also need to be specified on the `ffmpeg_microphone_live` function and passed through.
@jrhe jrhe added the Feature request Request for a new feature label Jul 6, 2024
@amyeroberts
Copy link
Collaborator

cc @kamilakesbi @sanchit-gandhi

@kamilakesbi
Copy link
Contributor

Hi @jrhe,

Thanks for submitting this issue!

There are indeed several requests to allow specifying the microphone in `ffmpeg_microphone' (see issues #31393 / #31074 / #28154).

It would be really nice if you could add this functionality with a PR. Perhaps you could include the changes suggested by @ruisilvestre in PR #31393 to select the default microphone by default (using :default instead of :0) and only change it if specified by the user.

Unfortunately, I'm also a Mac user. So far I haven't seen any issues with Linux/Windows, so it might be best to start with the first approach you suggested (just change the ffmepg input device parameter `-i'), and do a follow-up PR if there are new requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Audio Feature request Request for a new feature
Projects
None yet
Development

No branches or pull requests

3 participants