Alsa Pulse Audio 無法打開音頻設備 pulse (No such file or directory) pulse: Input/output error
我正在嘗試流式傳輸我安裝在我的 OpenVZ VPS 伺服器上的 Gnome 桌面,我並沒有嘗試從 SSH 執行它,而是從 GNOME 桌面內的終端執行,
我知道它可能沒有音效卡,但這不像我正在嘗試播放聲音,我只是想將它路由到流中。
在我的 PulseAudio 音量控制中
這是我嘗試流式傳輸時的樣子。
我嘗試的更多東西在這裡發生了更多錯誤
這是我執行
pacmd list-source-outputs
[removed@removed ~]$ pacmd list-source-outputs Welcome to PulseAudio! Use "help" for usage information. >>> 2 source outputs(s) available. index: 0 driver: <protocol-native.c> flags: DONT_MOVE state: RUNNING source: 0 <auto_null.monitor> current latency: 3.08 ms requested latency: 20.00 ms sample spec: float32le 1ch 25Hz channel map: mono Mono resample method: peaks owner module: 6 client: 4 <PulseAudio Volume Control> properties: media.name = "Peak detect" application.name = "PulseAudio Volume Control" native-protocol.peer = "UNIX socket client" native-protocol.version = "16" application.id = "org.PulseAudio.pavucontrol" application.icon_name = "audio-card" application.version = "0.9.10" application.process.id = "997" application.process.user = "removed_for_stackexchange(wasn't root)" application.process.host = "removed_for_stackexchange" application.process.binary = "pavucontrol" window.x11.display = ":1.0" application.language = "en_US.UTF-8" application.process.machine_id = "27be3273f5d5332051ccdc3100000002" application.process.session_id = "27be3273f5d5332051ccdc3100000002-1394085585.776225-694791372" module-stream-restore.id = "source-output-by-application-id:org.PulseAudio.pavucontrol" index: 1 driver: <protocol-native.c> flags: DONT_MOVE state: RUNNING source: 0 <auto_null.monitor> current latency: 3.11 ms requested latency: 20.00 ms sample spec: float32le 1ch 25Hz channel map: mono Mono resample method: peaks owner module: 6 client: 4 <PulseAudio Volume Control> direct on input: 2 properties: media.name = "Peak detect" application.name = "PulseAudio Volume Control" native-protocol.peer = "UNIX socket client" native-protocol.version = "16" application.id = "org.PulseAudio.pavucontrol" application.icon_name = "audio-card" application.version = "0.9.10" application.process.id = "997" application.process.user = "removed_for_stackexchange(wasn't root)" application.process.host = "removed_for_stackexchange" application.process.binary = "pavucontrol" window.x11.display = ":1.0" application.language = "en_US.UTF-8" application.process.machine_id = "27be3273f5d5332051ccdc3100000002" application.process.session_id = "27be3273f5d5332051ccdc3100000002-1394085585.776225-694791372" module-stream-restore.id = "source-output-by-application-id:org.PulseAudio.pavucontrol"
有關我正在使用的接收器的更多資訊
[removed@removed ~]$ pacmd list-sinks Welcome to PulseAudio! Use "help" for usage information. >>> 1 sink(s) available. * index: 0 name: <auto_null> driver: <module-null-sink.c> flags: DECIBEL_VOLUME LATENCY FLAT_VOLUME DYNAMIC_LATENCY state: RUNNING suspend cause: priority: 1000 volume: 0: 100% 1: 100% 0: 0.00 dB 1: 0.00 dB balance 0.00 base volume: 100% 0.00 dB volume steps: 65537 muted: no current latency: 3.49 ms max request: 3 KiB max rewind: 3 KiB monitor source: 0 sample spec: s16le 2ch 44100Hz channel map: front-left,front-right Stereo used by: 1 linked by: 3 configured latency: 20.00 ms; range is 0.50 .. 10000.00 ms module: 9 properties: device.description = "Dummy Output" device.class = "abstract" device.icon_name = "audio-card"
(希望)在底部改程序式碼
閱讀您自己的答案中提供的腳本,我對您的解決方案得出以下結論。請糾正我可能犯的任何/所有錯誤。
在
xwininfo $GAME_WINDOW
通過.tmp
_$GAME_WINDOW
_wmctl
在啟動轉儲之前,您有效地將tmp
文件截斷為 0 字節,rm -f
因為流是特定於會話的,或者為了避免tmp
文件變得太大,所以每個會話可能只發生一次,不過,我再次假設兩者。我基於這三行得出上述結論:> rm -f twitch_tmp 2> /dev/null > wmctrl -r "$GAME_WINDOW" -e 0, 411,51,160,144 > xwininfo -name "$GAME_WINDOW" >> twitch_tmp
雖然我對兩者都不是很熟悉,
wmctl
或者xwininfo
我知道它們是用於自動化各種X視窗行為的常見xorg實用程序。我假設您正在流式傳輸該數據集只是為了跟上可能發生的任何更改,因此可以對其轉碼做正確的事情,而不是像我懷疑的那樣通過以下兩個環境變數實際抽取實際的圖形/聲音源數據非常嚴重的是,如果有的話,後一種行為只會持續幾秒鐘:ffmpeg
> TOPXY=$(cat twitch_tmp | grep -oEe 'Corners:\s+\+[0-9]+\+[0-9]+' | grep -oEe '[0-9]+\+[0-9]+' | sed -e 's/\+/,/' ) > INRES=$(cat twitch_tmp | grep -oEe 'geometry [0-9]+x[0-9]+' | grep -oEe '[0-9]+x[0-9]+')
你在這裡:
- 打開兩個
$(command substitution)
子shell,一個for$TOPXY
和$INRES
value assignment。為
$TOPXY
您:
cat
將您的tmp
文件與stdin
匿名|pipe
結果合併為grep
’s whichstdin
then …
oEe
省略不包含字元串的任何行和未被省略的任何行的任何部分:
- “角落: ” 緊隨其後的是……
- 至少
+
一個\s
空格字元,然後…- 一個
\+
文字加號,然後…- 至少
+
一位[0-9]
數…- 另一個
\+
字面加…- 最後,至少
+
還有[0-9]
一位數字……結果是匿名
|piped
到另一個實例的,grep
該實例隨後-oEe
省略了您第一個擷取的[0-9]
數字之前的所有內容,然後匿名|pipe
將其結果…
sed
它將它收到的tr
所有文字加號轉換為逗號並轉儲到它的which is …\+``,``stdout
$TOPXY
最後通過$(command substituted)
子shell變數賦值擷取並儲存。的過程
$INRES
看起來大致相同,但稍微不那麼複雜。對我來說最值得注意的是整個
tmp
文件在每次呼叫cat
時至少被合併兩次,更不用說所有的|pipes
. 可能有很多方法可以做到這一點,但我無法想像這會是其中更好的方法。在此之後,您呼叫
ffmpeg
引用上面的兩個變數和各種其他選項,包括您還指定的其他環境變數:ffmpeg -f x11grab -s "$INRES" -r "$FPS" -i $DISPLAY+$TOPXY \ -f pulse -i default \ -vcodec libx264 -preset $PRESET -crf 30 -x264opts keyint=50:min-keyint=20 -s $INRES \ -acodec libmp3lame -ab $AUDIO_BITRATE -ar $AUDIO_RATE_HZ \ -threads 0 -pix_fmt yuv420p \ -f flv "rtmp://$SERVER.twitch.tv/app/$STREAM_KEY"
可能更直接
接下來的內容不涉及
tmp
文件,單個|pipe
,僅呼叫單個呼叫sed
和單個子shellcommand substitution
來解析您的幾何設置,並且包含在單個函式中。所有的環境變數都是在here-documents
流式中定義的stdin
,因此在本地範圍內有效。它們也是通過定義parameter-substitution
的,因此是可配置的。例如,要更改$FPS
單個呼叫的值,您只需執行以下操作:% FPS=28 desk_stream
不過,對於它的價值,我仍然認為
vlc
會是一個更好的選擇。desk_stream() { sed -rn '\ /.*((Corners:|geometry)\s*\+*([x|+|0-9]*\+)).*/{\ s//\3/;\ /X/s/.*/\ INRES="&";/p;\ s/(.*)\+(.*)\+$/\ DISPLAY='"${DISPLAY}"'"+\1,\2,";/p;\ };$a\. 0<&3 /dev/stdin\n' | . /dev/stdin } <<FFOPTS 3<<-\FFCMD ${FPS="15"} # target FPS ${PRESET="ultrafast"} # one of the many FFMPEG preset on (k)ubuntu found in /usr/share/ffmpeg ${THREADS="0"} #0 autostarts threads based on cpu cores. ${AUDIO_BITRATE="1k"} #Audio bitrate to 96k ${AUDIO_RATE_HZ ="44100"} #Audio rate 44100 hz ${GAME_WINDOW="MYGAMETEST"} ${STREAM_KEY=live_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx} ${SERVER="live-jfk"} # NY server $(wmctrl -r "$GAME_WINDOW" -e 0, 411,51,160,144 &&\ xwininfo -name "$GAME_WINDOW") FFOPTS ffmpeg -f x11grab -s "$INRES" -r "$FPS" -i $DISPLAY \ -f pulse -i default \ -vcodec libx264 -preset $PRESET -crf 30 -x264opts keyint=50:min-keyint=20 -s $INRES \ -acodec libmp3lame -ab $AUDIO_BITRATE -ar $AUDIO_RATE_HZ \ -threads 0 -pix_fmt yuv420p \ -f flv "rtmp://$SERVER.twitch.tv/app/$STREAM_KEY" FFCMD