How to initialize python-vlc without VLC installed on the machine (portable VLC intance)

594 views Asked by At

I am currently making some kind of a program that can control PCs using a remote control, and one of the features is music playing (In the background, the player will not be visible). I know that there are other options for that in python, but the only lightweight one is playsound, which cant pause and stop the music.

All the other packages increase the executable file size dramatically, so I decided to use VLC as a downloadable extension. Now, I don't want users to install VLC, just to download portable VLC libraries and use them to get VLC playing features. Any way to use python VLC bindings with potable version of VLC? (Without installing, that's the whole point)

Thank you!

3

There are 3 answers

0
Vexen Crabtree On

Specifically the python-vlc uses libvlc.dll and libvlccore.dll . On Windows machines, it places copies in /windows/system32/ . You could test copying just those two DLLs, rather than doing a full install.

1
Devil Ishere On

This is a cheeky solution. So what you want to do is install vlc on your PC then read bytes using

with open('vlc.exe', 'rb') as fa:
    fa.read() 

You have to do this with all dependencies. Then in your existing code. Add

with open('vlc.exe', 'wb') as g:
    g.write('your existing bytes') 

Then running the script on another pc will recreate vlc but they don't have to install and internet cost will not incur. Note that wb mode creates a new file but if it exists it will override it.

0
dreamAviator On

So I'm probably a little late, but this worked for me:

I downloaded a portable version of vlc (it probably also works with a normal vlc installation) and then put the plugins folder, libvlc.dll and libvlccore.dll in a folder in my project. Then I wrote this:

import os
dirname = os.path.dirname(__file__)
#with that I made the relative path into an absolute path
vlc_path = os.path.join(dirname,'vlc_folder')
#the plugins folder, libvlc.dll and libvlccore.dll is in the folder named vlc_folder which is in my project folder
os.environ['PATH'] += ';' + vlc_path
import vlc
#now importing the module should work

I got this answer using BingAi and other stackoverflow questions