如何使用 PulseAudio 从音频输出重定向到麦克风输入?
我正在为 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您进行搜索,
pactl
和pacmd
的手册很容易找到。我在这里找到它们:pactl
pacmd (pulse-cli-syntax)
我认为您感兴趣以下摘自
pactl
手册:您应该能够使用
pactl listink-inputs
、pactllistsource-outputs
、pactllistsinks
和pactllistsources
与一些grep
和/或sed
或类似性质的东西相结合,以编程方式确定正确的流和接收器。The manuals for
pactl
andpacmd
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:You should be able to use
pactl list sink-inputs
,pactl list source-outputs
,pactl list sinks
, andpactl list sources
combined with somegrep
and/orsed
or something of that nature to programmatically determine the correct stream and sink.