The client code does not play subtitles while stand-alone VLC instance does

51 views Asked by At

I am new to python-vlc and I am working on a simple movie streaming project. Sadly, I am facing an issue - The client code does not play subtitles.

I tried this code for server-side, and it successfully streamed the movie:

   video_path = "D:/movies/movie.mkv"   
   instance = vlc.Instance("--no-xlib")
   media = instance.media_new(video_path)
   media.add_option(':sout=#rtp{dst=localhost,port=5004,mux=ts}')
   player = instance.media_player_new()
   player.set_media(media)
   player.play()

On a stand-alone VLC instance (standard Windows VLC instance) I opened the network stream rtp://localhost:5004/ and it successfully played the movie with subtitles. However, Running the client-side program, did play the movie but without subtitles. I guess this means the server code is fine, but the client code is not. this is the client code:

   root = tk.Tk()
   root.geometry("800x600")
   frame = tk.Frame(root)
   frame.pack(fill="both", expand=True)
   instance = vlc.Instance("--no-xlib")
   media = instance.media_new('rtp://localhost:5004/')
   player = instance.media_player_new()
   player.set_media(media)
   player.set_hwnd(frame.winfo_id())
   player.play()
   root.mainloop()

Any ideas on how to solve this problem? Thanks!

Note: I don't show it here, but I used flask and the corresponding http request to tell the server to the start the streaming.

I tried using some subtitles relevant methods from vlc.py and wasn't sure if use them correctly.

0

There are 0 answers