ALSA 音频和 YouTube
我想播放 YouTube 视频并以编程方式将 Firefox 的音频输出到特定的声卡。
我想我会做类似 firefox | 的事情aplay -D hw:x,y。
产量:
播放原始数据“stdin”:无符号 8 位,速率 8000 Hz,单声道 aplay: set_params:1059: 示例格式不可用 可用格式: - S16_LE
尝试 Firefox | aplay -D hw:1,0 -f S16_LE -c 2
播放原始数据“stdin”:带符号的 16 位 Little Endian,速率 8000 Hz,立体声 警告:速率不准确(请求 = 8000Hz,得到 = 44100Hz) 请尝试该插件
最后,firefox | aplay -D Plughw:1,0 -f S16_LE -c 2
播放原始数据“stdin”:带符号的 16 位 Little Endian、速率 8000 Hz、立体声
命令行表明它有效,但音频来自 hw:0,0(默认值)。
我需要制作自己的插件吗? 或者我需要强制alsa采用44100Hz?
另外,我拒绝使用脉冲,因为内存泄漏错误使其经常崩溃。
I want to play youtube videos and programmatically direct firefox's audio out to a particular sound card.
I think I would do something like firefox | aplay -D hw:x,y.
Yields:
Playing raw data 'stdin' : Unsigned 8 bit, Rate 8000 Hz, Mono
aplay: set_params:1059: Sample format non available
Available formats:
- S16_LE
Trying firefox | aplay -D hw:1,0 -f S16_LE -c 2
Playing raw data 'stdin' : Signed 16 bit Little Endian, Rate 8000 Hz, Stereo
Warning: rate is not accurate (requested = 8000Hz, got = 44100Hz)
please, try the plug plugin
Finally, firefox | aplay -D plughw:1,0 -f S16_LE -c 2
Playing raw data 'stdin' : Signed 16 bit Little Endian, Rate 8000 Hz, Stereo
The command-line suggests that it worked, but audio came out of hw:0,0 (the default).
Do I need to make my own plugin?
Or do I need to force alsa to take 44100Hz?
Also, I refuse to use pulse since the memory leak bug makes it crash often.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我很确定 Flash 始终使用默认声卡,因此您需要更改
pcm.default
。您可以通过编辑~/.asoundrc
并添加以下内容来实现:当然,这会影响所有应用程序,但我相信也可以将
ALSA_CONFIG_PATH
(在环境中)设置为指定一个不同的文件,这样你就可以只为 Firefox 执行此操作。ALSA FAQ 指出有
ALSA_PCM_CARD
和ALSA_CARD
环境变量也可能起作用。这些变量实际上有效,因为它们是
/usr/share/alsa/alsa.conf
中默认配置的一部分:因此,您应该能够执行以下操作:
使用适当的卡和设备编号从您的系统。或者当然您可以将自己的环境变量(或其他条件检查)添加到 ALSA 配置中。
I'm pretty sure flash always uses the default sound card, so you need to change
pcm.default
. You could do so by editing~/.asoundrc
and adding something like:Of course, that affects all apps, but I believe can also set
ALSA_CONFIG_PATH
(in the environment) to specify a different file, so you could do it for just Firefox.The ALSA FAQ indicates there are
ALSA_PCM_CARD
andALSA_CARD
environment variables that may work as well.These variables actually work because they're part of the default also config in
/usr/share/alsa/alsa.conf
:So, you should be able to do this:
using the appropriate card and device numbers from your system. Or of course you could add your own environment variable (or other conditional check) into your ALSA configuration.
Flash 使用自己的输出配置,独立于 Firefox。在运行浏览器之前定义 FLASH_ALSA_DEVICE,它告诉 Flash 使用什么 ALSA PCM 而不是默认值。
Flash uses its own output config, independent of Firefox. Define FLASH_ALSA_DEVICE before running your browser, it tells Flash what ALSA PCM to use instead of the default.