如何使用 PulseAudio 从音频输出重定向到麦克风输入?

发布于 2024-10-12 15:23:36 字数 870 浏览 4 评论 0原文

我正在为 Maemo/MeeGo 开发移动应用程序,Maemo 使用 PulseAudio。我想向呼叫者播放 mp3(并在执行此操作时取消麦克风,而不是听呼叫者,一切都应该在后台完成),为此,我必须从某个(如果不可能,所有)应用程序,将其伪造为输入并让电话应用程序使用它。

在我的 Ubuntu PC 上,我使用 pavucontrol 完成此操作。我创建了一个 NULL 接收器,然后:

Audio Output (from Amarok) --> to NULL Output 
Skype Input <-- NULL Output
Skype Output --> NULL

它起作用了,Amarok 播放了音乐,它流式传输到 Skype,但没有播放给我听,我没有听到有关所有过程的任何信息。问题是; a) Maemo 没有 pavucontrol。 b)即使它确实如此(或者如果我打包它)它也不会有任何好处,因为它是一个唯一的 GUI 应用程序,我必须在后台完成所有这些工作,没有任何用户输入。 (意思是:CLI 或 API)

在 Freenode #pulseaudio 上询问这个问题,一个乐于助人的人说“这几乎可以通过 pactl 或 pacmd 完成,你想要的命令是 move-sink-input 和 move-source-output,但是你需要知道设备和流索引。”所以看起来 pavucontrol 只是一个 GUI,pactl 和 pacmd 才是真正的交易,最重要的是,它们是 CLI 应用程序。

我真的很感谢他,但我对“pactl”、“pacmd”、“move-sink-input”或“设备/流索引”一无所知,所以我需要一个非常简化的手册页,或者一个来源类似的应用程序,一个单行命令(两个?整页命令?,只要给我它们!^^)或者有足够耐心向我解释这些东西的人。

I'm working on a mobile app for Maemo/MeeGo and Maemo uses PulseAudio. I want to play a mp3 to caller (and cancel the mic when doing it, and not to listen caller, everything should be done on background), to do this, I have to redirect Audio Output from a certain (if not possible, all) app, fake it as a Input and make Phone app use it.

On my Ubuntu PC, I did it with pavucontrol. I created a NULL sink, then:

Audio Output (from Amarok) --> to NULL Output 
Skype Input <-- NULL Output
Skype Output --> NULL

And It worked, Amarok played the music and It was streaming to Skype, without playing it to me and I didn't hear anything about all process. Problem is;
a) Maemo does not have pavucontrol.
b) Even If it did (or if I package it) It wouldn't be any good since It's a only-GUI app and I have to do all of this stuff on background, without any user input. (mean: CLI or API)

Asked about this on Freenode #pulseaudio and a helpful guy said "It can pretty much be done via pactl or pacmd, the commands you want are move-sink-input and move-source-output, but you need to know device and stream indexes." So It looks like pavucontrol is just a GUI, pactl and pacmd are the real deal, and most importantly, they're CLI apps.

I'm really thankful to him but I don't know anything about "pactl", "pacmd", "move-sink-input" or "device/stream indexes" so I need a very simplified manual page, or a source of similar app, a one-liner command (two? whole page of commands?, just give me them! ^^) or someone with enough patience to explain this stuff to me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黯然#的苍凉 2024-10-19 15:23:36

如果您进行搜索,pactlpacmd 的手册很容易找到。我在这里找到它们:

pactl

pacmd (pulse-cli-syntax)

我认为您感兴趣以下摘自 pactl 手册:

移动接收器输入 ID 接收器:
将指定的播放流(由其数字索引标识)移动到指定的接收器(由其符号名称或数字索引标识)。

您应该能够使用 pactl listink-inputspactllistsource-outputspactllistsinkspactllistsources 与一些 grep 和/或 sed 或类似性质的东西相结合,以编程方式确定正确的流和接收器。

The manuals for pactl and pacmd are readily available if you give it a search. I found them here:

pactl

pacmd (pulse-cli-syntax)

I think you are interested in the following excerpt from the pactl manual:

move-sink-input ID SINK :
Move the specified playback stream (identified by its numerical index) to the specified sink (identified by its symbolic name or numerical index).

You should be able to use pactl list sink-inputs, pactl list source-outputs, pactl list sinks, and pactl list sources combined with some grep and/or sed or something of that nature to programmatically determine the correct stream and sink.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文