Can I stream a file with python VLC?

1.6k views Asked by At

I want to stream a file over the network with python-vlc. How can I do that ?

I tried this :

import vlc

arg = ":sout=#http{mux=ffmpeg{mux=flv},dst=:8080/} :no-sout-all :sout-keep"

inst = vlc.Instance(arg)

media = inst.media_new("rtsp://192.168.0.50:554/onvif1")
player = media.player_new_from_media()
player.play()
input()

But a window appeared (I don't want a window to appear) and the stream doesn't work.

Can someone help me ? Thanks !

P.S. : I tried to get a rtsp stream with open cv, but that was bugged, and with VLC, no problem. So I want to capture the VLC stream with opencv, instead of the rtsp stream.

1

There are 1 answers

1
mfkl On BEST ANSWER
arg = ":sout=#http{mux=ffmpeg{mux=flv},dst=:8080/} :no-sout-all :sout-keep"
inst = vlc.Instance(arg)

This seems wrong. The arguments fed to vlc instance should take the form of --, not :.

But these arguments should be added to the media as an option, not the vlc instance. And call add_media_option 3 times, instead of once with space (this is likely invalid).

Feel free to share logs if this isn't sufficient to get it working. If you want to disable the video output, use --no-video in the vlc instance constructor.