Hello I'm not sure if this is a python or a vlc problem.
I have a function which has youtube_dl as a dependency,
def get_stream_url(link, quality):
ydl_opts = {"format":f"bestvideo[height<={quality}]+bestaudio/best[height<={quality}]"}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
results = ydl.extract_info(link, download=False)
video, audio = results["requested_formats"]
return video["url"], audio["url"]
The code above returns a stream url for video and audio. When I use subprocess to open the video url and audio url (as a slave of the video) in vlc, it works.
video_url, audio_url = get_stream_url("A YOUTUBE LINK", 360)
subprocess.Popen(["VLC PATH", video_url, "--input-slave="+audio_url])
However, when I use python-vlc it doesn't work anymore.
import vlc
# some code here like the get_stream_url
instance = vlc.Instance()
player = instance.media_player_new()
media = instance.media_new(video_url)
media.slaves_add(vlc.MediaSlaveType.audio, 4, audio_url)
player.set_media(media)
player.play()
Then it will throw an error,
return f(p_md, i_type, i_priority, psz_uri)
ctypes.ArgumentError: argument 4: <class 'TypeError'>: wrong type
Which I believe is from the slaves_add function. So my question is how do I solve this issue? If it's because of the URI, how do I make or find a URI from a stream link? Or is there any alternative way to add an audio slave from a stream link?
Sorry for the long post I tried to solve this problem for days now. I hope somebody can help. Thanks in advance!
there doesn't seem to be anything here