Linux 如何使用 PulseAudio 从音频输出重定向到麦克风输入?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4719160/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to redirect from Audio Output to Mic Input using PulseAudio?
提问by Yekta Leblebici
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.
我正在为 Maemo/MeeGo 开发移动应用程序,而 Maemo 使用 PulseAudio。我想向来电者播放 mp3(并在这样做时取消麦克风,而不是听来电者,一切都应该在后台完成),为此,我必须从某个(如果不可能,所有)重定向音频输出) 应用程序,将其伪装为输入并让电话应用程序使用它。
On my Ubuntu PC, I did it with pavucontrol. I created a NULL sink, then:
在我的 Ubuntu PC 上,我用 pavucontrol 做到了。我创建了一个 NULL 接收器,然后:
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)
它奏效了,Amarok 播放了音乐并且它正在流式传输到 Skype,没有播放给我,我没有听到任何关于所有过程的信息。问题是; a) Maemo 没有 pavucontrol。b) 即使它做了(或者如果我打包它)也不会有任何好处,因为它是一个唯一的 GUI 应用程序,我必须在后台完成所有这些工作,没有任何用户输入。(意思是:CLI 或 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.
在 Freenode #pulseaudio 上被问到这个问题,一个乐于助人的人说“它几乎可以通过 pactl 或 pacmd 来完成,你想要的命令是 move-sink-input 和 move-source-output,但你需要知道设备和流索引.” 所以看起来 pavucontrol 只是一个 GUI, pactl 和 pacmd 是真正的交易,最重要的是,它们是 CLI 应用程序。
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.
我真的很感谢他,但我对“pactl”、“pacmd”、“move-sink-input”或“设备/流索引”一无所知,所以我需要一个非常简化的手册页,或类似的应用程序,单行命令(两个?整页命令?,给我它们!^^)或有足够耐心向我解释这些东西的人。
采纳答案by izzy
The manuals for pactl
and pacmd
are readily available if you give it a search. I found them here:
如果您进行搜索pactl
,pacmd
则可以轻松获得和的手册。我在这里找到了它们:
I think you are interested in the following excerpt from the pactl
manual:
我认为您对pactl
手册中的以下摘录感兴趣:
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).
move-sink-input ID SINK :将指定的播放流(由其数字索引标识)移动到指定的接收器(由其符号名称或数字索引标识)。
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.
您应该能够使用pactl list sink-inputs
, pactl list source-outputs
, pactl list sinks
, 并pactl list sources
结合某些grep
和/sed
或某种性质的东西以编程方式确定正确的流和接收器。