I have learnt how to use python subprocess to open a video file in vlc using the code:
import os, subprocess
vlcPath = "C:/Program Files/VideoLAN/VLC/vlc.exe"
vid = "vid.mp4"
aud = "aud.mp3"
aud2 = "aud2.mp3"
#To open just the video in vlc, the following code works:
subprocess.Popen([vlcPath, vid])
Now how can I make this code load the other audio files so that they are simultaneously loaded as codecs and a user can easily switch between a particular audio file from vlc.
I am able to achieve simultaneous streaming from vlc directly, by setting option to one more file, by clicking the option "Play another media asynchronously (extra audio file,...)" and adding the path in the extra media section.
When doing so vlc adds an option saying ":input-slave=[filename]"
Now how can I do the same in python because the following did not work:
subprocess.Popen([vlcPath, vid, aud, aud2])
OR
subprocess.Popen([vlcPath, "{} :input-slave={}".format(vid, aud)])
OR
subprocess.Popen([vlcPath, vid, ":input-slave=", aud, ":input-slave=", aud2])
The first and third solution i tried above, open all index items after "vlcPath", as seperate items in the vlc playlist. The second solution leads me to an error.
I have tried my best to explain my question in detail, however please feel free to ask me if you need more details, i will try my best to answer your questions.
Thank you.
Ok, I just found a solution to my own question.
I found the solution from Synetech's answer in the following post: https://superuser.com/questions/685507/how-to-play-a-soundless-video-and-add-a-audio-file-at-the-same-time
To make it work all i tried to do was to add --input-slave= to the audio file, e.g.:
subprocess.Popen([vlcPath, vid, "--input-slave="+aud])
Although, this works, if i try to add the other audio using this method it does not work, i.e.:
subprocess.Popen([vlcPath, vid, "--input-slave="+aud, "--input-slave="+aud2])
This does not work.
So if you have a solution for this aswell, it would be helpful.
Thank you.