How to start multiple vlc's each with unique unix socket

macOS specific usage questions
crackstone
Blank Cone
Blank Cone
Posts: 56
Joined: 01 Apr 2010 17:25
VLC version: 2.1.0-git
Operating System: Mac OS X
Location: Vienna, Austria

How to start multiple vlc's each with unique unix socket

Postby crackstone » 27 Jul 2010 19:20

Hi VLC community,

this is my question: How do I start multiple vlc instances via command line and have each vlc instance connected with a unique unix socket?
and this is the story behind it:

I'm using VLC successfully to stream, produce snapshots, and play the stream on another Mac. My environment is Mac OS X 10.6.4
All of those things work fine - my next goal is to control all of this via applescript and a small GUI.

Ultimate idea: I need to control VLC via shell scripts e.g.:

Code: Select all

set openCMD to "/Applications/VLC.app/Contents/MacOS/VLC udp://@224.0.0.1:1234 --no-osd &>/dev/null &" do shell script openCMD
Now this works perfectly but I am running multiple instances of VLC
1 - continous snapshots with scene video filter;
2 - record stream;
3 - play stream fullscreen on another display

Hence I want to be able to control each VLC instance seperately via shell commands which I can issue over Applescript.
I read this tut http://n0tablog.wordpress.com/2009/02/0 ... ogramming/ on setting up VLC with a unix socket via GUI preferences - works like a charm BUT (and this is my actual question) how can I start VLC via command line and assign a unique (vlc1.sock vlc2.sock vlc3.sock) unix socket to each instance.

Vlc -H gave me some direction with the --rc flags, I tried the following but without success:

Code: Select all

/Applications/VLC.app/Contents/MacOS/VLC udp://@224.0.0.1:1234 --no-osd --extraintf=rc --rc-unix=/Users/kalliope/vlc1.sock --rc-fake-tty
I also tried putting the --rc flags before the stream but without success (video plays, but no socket created)

Is this the correct approach? Maybe I'm missing some arguments?
Does anyone have a solution or experience with this question?

I'm glad for any input, direction or hint

Thx
VLC rocks

-crackstone

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: How to start multiple vlc's each with unique unix socket

Postby Jean-Baptiste Kempf » 27 Jul 2010 22:21

I am afraid RC is a bit buggy on OSX...
I would use http intf with different ports, but that may get more difficult.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

crackstone
Blank Cone
Blank Cone
Posts: 56
Joined: 01 Apr 2010 17:25
VLC version: 2.1.0-git
Operating System: Mac OS X
Location: Vienna, Austria

Re: How to start multiple vlc's each with unique unix socket

Postby crackstone » 05 Aug 2010 18:17

Just looked into it again and followed another hint on the web by just using the following command:

Code: Select all

vlc --rc-unix=/Users/user/socket1
I start a stream manually with this instance just for testing purposes
and

Code: Select all

vlc --rc-unix=/Users/user/socket2 udp://@224.0.0.1:1234
Somehow the video won't auto play when issuing this command but
the sockets are created successfully and I can communicate to them via the following commands:

for example

Code: Select all

echo play | nc -U /Users/user/socket2
and

Code: Select all

echo fullscreen | nc -U /Users/user/socket2
and can of course communicate to the streaming instance as well

Code: Select all

echo stop | nc -U /Users/user/socket1
This should suffice for the time being - I'll see what bumps up next.

@j-b: could you maybe elaborate on the buggy issues? Any known bugs?

Thx for the input

LuukS
New Cone
New Cone
Posts: 4
Joined: 26 Aug 2015 14:21

Re: How to start multiple vlc's each with unique unix socket

Postby LuukS » 03 Jan 2019 01:26

I am using this both on my macosx and linux and it works well.
On linux the shell commands are slightly different:

Code: Select all

vlc -I oldrc --rc-unix=/home/user/Documents/Sockets/socket1.sock vlc -I oldrc --rc-unix=/home/user/Documents/Sockets/socket2.sock
and

Code: Select all

echo play | nc -U /home/user/Documents/Sockets/socket1.sock echo enqueue /home/user/Documents/DualscreenVLC/videos/MVI_2534.MP4 | nc -U /home/user/Documents/Sockets/socket1.sock
I am attempting to use subprocess.Popen in Python for further control but here I run into difficulties on Linux (Ubuntu). It either hangs on the stdout.read() call or when I take this away, all the shell commands are only executed after the script finishes and I get a broken pipe error. The issue seems to be specifically with the 'echo' commands. Did I migrate wrong?
This is the python script:

Code: Select all

import subprocess import time Socket1Location = "/Users/user/socket1.sock" Socket2Location = "/Users/user/socket2.sock" video1 = "/Users/user/Documents/Scripts/DualscreenVLC/videos/video01.mp4" video2 = "/Users/user/Documents/Scripts/DualscreenVLC/videos/video02.mp4" def RunVLCCommand1(cmd): p = subprocess.Popen("echo " + cmd + " | nc -U " + Socket1Location, shell = True, stdout = subprocess.PIPE) errcode = p.wait() retval = p.stdout.read() print "returning: " + retval return retval def RunVLCCommand2(cmd): p = subprocess.Popen("echo " + cmd + " | nc -U " + Socket2Location, shell = True, stdout = subprocess.PIPE) errcode = p.wait() retval = p.stdout.read() print "returning: " + retval return retval subprocess.Popen(["/Applications/VLC.app/Contents/MacOS/VLC","--rc-unix=/Users/user/socket1.sock"]) subprocess.Popen(["/Applications/VLC.app/Contents/MacOS/VLC","--rc-unix=/Users/user/socket2.sock"]) #RunVLCCommand1 and 2 can now be used to send commands to VLC

unidan
Developer
Developer
Posts: 1493
Joined: 25 Mar 2018 01:00

Re: How to start multiple vlc's each with unique unix socket

Postby unidan » 03 Jan 2019 09:47

Hi, subprocess is used to open a process. As you want to execute bash code (with the pipe syntax), you might want to start bash:

Code: Select all

p = subprocess.Popen("bash -c 'echo " + cmd + " | nc -U " + Socket1Location + "'", shell = True, stdout = subprocess.PIPE)

LuukS
New Cone
New Cone
Posts: 4
Joined: 26 Aug 2015 14:21

Re: How to start multiple vlc's each with unique unix socket

Postby LuukS » 04 Jan 2019 05:27

Thank you for the suggestion.
I tried it out but it also seems like it hangs. In the activity monitor I can see the two vlc instances but also a sh (shell) for each echo command I have send. When I add bash it replaces the sh instances with bash. Does this mean I am trying to execute scripts in wrong shells?


Return to “VLC media player for macOS Troubleshooting”

Who is online

Users browsing this forum: No registered users and 17 guests