Start vlc server/client from web interface (php - sh - vlc)

All you've ever wanted to know about the ActiveX, Mozilla plugins, the web interface and various PHP extensions
Geojj
New Cone
New Cone
Posts: 2
Joined: 14 Dec 2013 03:29

Start vlc server/client from web interface (php - sh - vlc)

Postby Geojj » 14 Dec 2013 13:00

I’m experiencing problems for the use of vlc streaming, hopefully embedded into a web page, starting vlc server and client from web interface.

(I have full access to the web server, Ubuntu 12.04, Apache, Php, MySQL.) (I'm using VLC media player 2.0.8 TwoFlowers)

There are 2 different problems.

1st. (Most important)
I need to start the VLC player from the web interface (even if working directly on the server machine).
The aim is to generate a vlc video stream from a server machine, send it using UDP through a network which then returns it to the server.
Cutting off the network role, the server can stream the video to its own IP, to the port it is listening on.

I put these commands in a shell script:
video_flow.sh:

Code: Select all

#!/bin/sh # Start vlc server listening on udp port 8000 (trying to pass the the x11 display to use) /usr/bin/cvlc --x11-display :0 udp://@192.168.1.5:8000/0 & sleep 1 # Start vlc client streaming to the server's ip and udp port 8000 /usr/bin/cvlc -I dummy /full/path/to/video.mpg --sout '#transcode{vcodec=h264,vb=800,scale=1,acodec=mpga,ab=128,channels=2,samplerate=44100}:std{access=udp,mux=ts,dst=192.168.1.5:8000}' &
The script works if executed from command line: vlc server listen to port udp 8000 and vlc client streams the video to the same udp port; the vlc window opens and plays the video as expected.

The trouble is that I need the script to be executed from the web interface.
video_flow.php:

Code: Select all

shell_exec("sh /full/path/to/video_flow.sh > /full/path/to/video_debug.log 2>&1 & echo $!;");
Started this way, from web interface via php, vlc server and client start but do not open any window and return several error messages:

Code: Select all

> inhibit interface error: Failed to connect to the D-Bus session daemon: //bin/dbus-launch terminated abnormally with the following error: No protocol specified Autolaunch error: X11 initialization failed. ... > main interface error: no suitable interface module ... > xcb_xv vout display error: parent window not available ...
I know the server and client are running because I can see the processes running and if I duplicate the output to a file, other than to the display, it correctly creates the file.

I tried to export the display...

Code: Select all

export DISPLAY=:0
to pass user’s credentials to the vlc command...

Code: Select all

/usr/bin/cvlc --x11-display :0 udp://USER_NAME:USER_PASSWORD@192.168.1.5:8000/0 &
and to the shell_exec command...

Code: Select all

shell_exec('echo USER_PASSWORD | sudo –u USER_NAME –S "sh /full/path/to/video_flow.sh" > /full/path/to/video_debug.log 2>&1 & echo $!;');
No way, it doesn’t make any change or generates "sudo error" for user www-data...

If I grant connections to the X server to the network user www-data

Code: Select all

xhost +local:www-data
The php shell_exec call works for the video but without audio: the VLC window pops up and plays the video as wanted but no audio... and still several error messages.

Code: Select all

> pulse audio output error: PulseAudio server connection failure: Connection refused ... > alsa audio output error: cannot open ALSA device "default": No such file or directory ... > main audio output error: no suitable audio output module
2nd. (Secondary importance)
After that problem number 1 will be solved, it would be nice to have the video embedded into a web page, instead of having it playing in its original player window.

I've set VLC to use the http interface from the VLC GUI, preferences.
I've created an asx file on the apache server:
stream1.asx

Code: Select all

<ASX version ="3.0"> <TITLE>Stream1</TITLE> <ENTRY> <REF HREF="http://192.168.1.5:8000" /> </ENTRY> </ASX>
and a php file to access the video:
flow.php

Code: Select all

<embed src="/full/path/to/stream1.asx" height="370" width="400">
I've tried to stream from the VLC GUI as described in the videolan wiki (https://wiki.videolan.org/Simple_Stream_VLC_to_Website/):
Select file and stream http on defined port transcode to WMV/ASF with enough ttl

Code: Select all

:sout=#transcode{vcodec=WMV2,vb=800,scale=1,acodec=wma2,ab=128,channels=2,samplerate=44100}:duplicate{dst=http{mux=asf,dst=:8000/},dst=display} :ttl=5 :sout-keep
no way, it doesn’t work: the flow.php page shows the embedded video frame but it is empty; no data.

Any help would be really appreciated.

Geojj
New Cone
New Cone
Posts: 2
Joined: 14 Dec 2013 03:29

Re: Start vlc server/client from web interface (php - sh - v

Postby Geojj » 14 Dec 2013 13:20

..."from web interface", I mean from the browser (Chrome).

xha1e
New Cone
New Cone
Posts: 5
Joined: 26 Feb 2024 06:48

Re: Start vlc server/client from web interface (php - sh - vlc)

Postby xha1e » 27 Feb 2024 05:04

did you ever resolve this issue?


Return to “Web and scripting”

Who is online

Users browsing this forum: No registered users and 6 guests