I want to play a video from a pipe, and I try to use python-vlc.(I'm not prefer to use subprocess.Popen
because I need to embedded the VLC window into pyqt)
I tried a simple code like this.
import os, time, vlc
r, w = os.pipe()
instance = vlc.Instance()
mediaplayer = instance.media_player_new()
mediaplayer.set_media(instance.media_new_fd(r))
mediaplayer.play()
time.sleep(5)
But got the following error message:
filesystem stream error: cannot open file \\3 (Bad file descriptor)
main input error: 您的输入无法被打开(Your input cannot be open)
main input error: VLC 无法打开 MRL「fd://3」。详情请检查日志。(VLC is unable to open the MRL fd://3, please check the log for detial)
I tried to switch the pipe to an opened fd, but nothing changed.
...
fd = os.open('test.mp4')
...
mediaplayer.set_media(instance.media_new_fd(fd))
...
I tried to use filename directly, then everything goes well.
mediaplayer.set_mrl('test.mp4')
I'm not sure what's wrong with my code. Thank you for your help!
I run the script on Win 10 x64, with python 3.8, VLC 3.0.11.