环境 ubuntu 18.04. 启用了pulseaudio
-
/usr/bin/pulseaudio --daemonize=no
外置 USB 声卡, 通过一个 USB 3.0 HUB扩展出来, mainboard为TX2, USB3.0支持.
-
mplayer /home/nvidia/oooo.mp3
-
-
出现 Starting playback...
-
A: 1.2 (01.1) of 261.0 (04:21.0) 1.5%
-
Audio device got
-
A: 1.7 (01.6) of 261.0 (04:21.0) 1.5%
-
Audio device got
-
A: 1.7 (01.6) of 261.0 (04:21.0) 1.5%
-
-
现象为头播放了一会, 然后出现 Audio device got stuck 时, 就没有声音了, 然后一直停留在 1.5%的状况.
-
这种情况不是每次都出现, 但是概率较高.
-
这个应该可以pulseaudio有关系.
-
因为使用 mplayer -ao alsa:device=hw=2 /home/nvidia/oooo.mp3 是正常的, 即绕开了pulseaudio.
2. 在pullseaudio 开启情况下, 调用
-
aplay -Dplughw:2 /home/nvidia/robot/data/voicefile/poetry/悯农.wav
-
aplay: main:788: audio open error: Device or resource busy
-
直接出错.
-
-
而直接使用 sudo
-
sudo aplay -Dplughw:2 /home/nvidia/robot/data/voicefile/poetry/悯农.wav
-
这样播放正常.
-
-
权限是肯定要提升的.
动态确定网卡序号.
card_idx=`aplay -l | grep 'USB Audio' | tail -n 1 | awk -F '[ :]' '{print $2}'`; echo "sudo mplayer -ao alsa:device=hw=$card_idx /usr/share/sounds/alsa/Noise.wav"
-
mplayer -ao alsa:device=hw=2 /usr/share/sounds/alsa/Rear_Right.wav -novm
-
-
aplay -Dplughw:2 /usr/share/sounds/alsa/Rear_Right.wav
-
-
使用 alsa dimxer
-
-
nvidia@tegra-ubuntu:~$ cat /etc/asound.conf
-
pcm.!default {
-
type plug
-
slave.pcm "dmix_n2"
-
}
-
-
pcm.dsp0 {
-
type plug
-
slave.pcm "dmix_n2"
-
}
-
-
pcm.dmix_n2 {
-
type dmix
-
ipc_key 101
-
ipc_key_add_uid true
-
slave {
-
pcm "hw:2"
-
format S32_LE
-
rate 44100
-
period_time 0
-
period_size 1024
-
buffer_size 8192
-
}
-
bindings {
-
0 0
-
1 1
-
}
-
}ctl.dmix_n2 {
-
type hw
-
card 2
-
}
-
-
pcm.dmix_n6 {
-
type dmix
-
ipc_key 101
-
ipc_key_add_uid true
-
slave {
-
pcm "hw:6"
-
format S32_LE
-
rate 44100
-
period_time 0
-
period_size 1024
-
buffer_size 8192
-
}
-
bindings {
-
0 0
-
1 1
-
}
-
}ctl.dmix_n6 {
-
type hw
-
card 6
-
}
-
-
然后播放变成
-
aplay -Dplug:dmix_n2 /usr/share/sounds/alsa/Rear_Right.wav
-
-
mplayer -ao alsa:device=plug=dmix_n2 /usr/share/sounds/alsa/Rear_Right.wav -novm
-
-
但是 mplayer 是必须要基于pulseaudio的, 如果仅仅是播放, 那么ffmpeg的 ffplay就够用了.
-
ffmpeg 和 mplayer 没有依存关系.
-
-
nvidia@tegra-ubuntu:/work/3th/ffmpeg-3.3.4$ cat make.txt
-
sudo apt install sox libsox-fmt-mp3
-
sudo apt install libmp3lame0 libmp3lame-dev
-
sudo apt install libogg0 libogg-dev
-
sudo apt install libvorbis0a libvorbisenc2 libvorbisfile3
-
sudo apt install xvidenc xvid4conf x264 x265 libx264-dev libx265-dev sudo apt install libsdl2-dev libsdl2-2.0-0
-
./configure --enable-shared --prefix=/usr/local/ffmpeg --enable-libmp3lame --enable-gpl --enable-version3 --enable-nonfree --enable-pthreads --enable-postproc --enable-ffserver --enable-ffplay --enable-libx264 --enable-libxvid
-
-
-
modify -> config.h / config.mak --> enable ffplay
-
-
make -j8; sudo make install
-
-
echo "export PATH=/usr/local/ffmpeg/bin:$PATH" >> /etc/profile
-
source /etc/profile
-
echo "/usr/local/ffmpeg/lib" >> /etc/ld.so.conf
-
ldconfig
阅读(2515) | 评论(0) | 转发(0) |