2017-05-27 43 views
0

我試圖在python中將h264傳遞給vlc。在Popen中打開cvlc程序時遇到問題。這是代碼。在Python中通過Popen調用cvlc時出錯

self.vlc = subprocess.Popen([ 
    "cvlc", "-vvv", "stream:///dev/stdin", "--sout \'#rtp{sdp=rtsp://:8554/}\' :demux=h264" 
    ], stdin=subprocess.PIPE) 

這是

vlc: unknown option or missing mandatory argument `--sout '#rtp{sdp=rtsp://:8554/}' :demux=h264' 

我一直在試圖弄清楚這一點對於不同類型的字符串格式化的小時VLC錯誤。

+0

有一個--sout參數,如[https:// wiki.videolan.org/Documentation:Streaming_HowTo/Command_Line_Examples/#RTSP_live_streaming),結果是子過程不能很好地處理參數中的空格。 [這原來是我的解決方案。](https://stackoverflow.com/questions/25655173/is-python-subprocess-popen-accept-space-in-path/25655627#25655627) –

+0

shlex.split工程甚至更好,我發佈了工作代碼[在這裏](https://raspberrypi.stackexchange.com/questions/59512/raspberry-streaming-using-vlc-picamera-python/68806#68806)。感謝您的幫助,不要以爲我會以其他方式工作 –

回答

0

問題:我在打開cvlc程序時打電話給Popen時遇到了問題。

使用shlex.quote(..。獲取參數的shell轉義版本。

的Python 3.6文檔:shlex.quote

shlex.quote(s)
返回的字符串s殼逸出版本。返回的值是一個字符串,可安全地用作shell命令行中的一個標記,用於不能使用列表的情況

相關問題