python-vlc http streaming doesn't work but same args work fine from CLI
Posted: 22 Aug 2021 22:38
Hi guys,
I've been trying to get python-vlc to take a simple .mp3 file and push it out via an http stream on a Raspberry Pi 3, running Raspberry Pi OS. For some reason, if I run the following CLI command, it works just fine:
I can connect to that stream without any issues. However, when I try to execute the following python code, it doesn't work:
In the debug output, I can see when I run it from CLI, there are lots of lines referring to avcodec encoder, however when I run the python version, I don't see any of this, it just tries to push the audio out via alsa. It's got me tearing my hair out somewhat as I don't fully understand why the python version seems to be ignoring the fact I want to stream.
It's got me stumped, so I would be appreciative for any assistance.
Cheers,
Lachlan.
I've been trying to get python-vlc to take a simple .mp3 file and push it out via an http stream on a Raspberry Pi 3, running Raspberry Pi OS. For some reason, if I run the following CLI command, it works just fine:
Code: Select all
vlc ./test.mp3 --verbose 3 --no-video --sout '#transcode{vcodec=none,acodec=mp3}:std{mux=mp3,dst=:8080/stream,access=http}' --sout-all --sout-keep --loop
I can connect to that stream without any issues. However, when I try to execute the following python code, it doesn't work:
Code: Select all
import vlc
instance = vlc.Instance("--verbose 3 --no-video --sout '#transcode{vcodec=none,acodec=mp3}:std{mux=mp3,dst=:8080/stream,access=http}' --sout-all --sout-keep --loop")
player = instance.media_player_new()
media = instance.media_new('/code/fiddling/test.mp3')
player.set_media(media)
player.play()
while True:
pass
In the debug output, I can see when I run it from CLI, there are lots of lines referring to avcodec encoder, however when I run the python version, I don't see any of this, it just tries to push the audio out via alsa. It's got me tearing my hair out somewhat as I don't fully understand why the python version seems to be ignoring the fact I want to stream.
It's got me stumped, so I would be appreciative for any assistance.
Cheers,
Lachlan.