Joe Stagner
Joe Stagner

Reputation: 73

VLC HTTP Streaming - Works from CMD but not from Python

Hoping someone can help me solve this puzzle.

Using python-vlc 3.0.16120 - I'm trying to stream over http from a Python script on Windows.

It works using this command line:

"C:\Program Files\VideoLAN\VLC\vlc.exe" sample-mp4-file.mp4 --sout="#transcode{vcodec=h264,acodec=mpga,ab=128,channels=2,samplerate=44100,scodec=none}:duplicate{dst=http{mux=ffmpeg{mux=flv},dst=:8080/}", :no-sout-all :sout-keep

However, this code (using the same sout) doesn't seem to work.

import vlc
inst = vlc.Instance("""--sout="#transcode{vcodec=h264,acodec=mpga,ab=128,channels=2,samplerate=44100,scodec=none}:duplicate{dst=http{mux=ffmpeg{mux=flv},dst=:8080/}", :no-sout-all :sout-keep""")
med = inst.media_new("sample-mp4-file.mp4")
p = med.player_new_from_media()
p.play()

while True:
pass

Does anyone have any suggestions

TIA

Upvotes: 2

Views: 1293

Answers (1)

Joe Stagner
Joe Stagner

Reputation: 73

This code works- don't ask me why

import vlc

inst  = vlc.Instance()
param=[
    "sample-mp4-file.mp4"
    ,"sout=#transcode{vcodec=h264,acodec=mpga,ab=128,channels=2,samplerate=44100,scodec=none}:duplicate{dst=http{mux=ffmpeg{mux=flv},dst=:8080/}"
    ]
Media = inst.media_new(*param)
player = Media.player_new_from_media()
player.play()

while True:
     pass

Upvotes: 2

Related Questions