Starting VLC = ok, but starting from PHP only works local

All you've ever wanted to know about the ActiveX, Mozilla plugins, the web interface and various PHP extensions
aux
New Cone
New Cone
Posts: 4
Joined: 26 Aug 2006 19:27

Starting VLC = ok, but starting from PHP only works local

Postby aux » 14 Jan 2007 16:17

Hi,

I made a PHP script which starts streaming

stream.php

Code: Select all

<?php $output = "/usr/bin/vlc /-vvv --daemon http://192.168.1.2/video.m3u :sout='#transcode{acodec=mpga,vcodec=DIV3,ab=60,vb=150,scale=0.50,deinterlace,fps=15,channels=1,width=240,height=192}:std{access=http,mux=ts,url=192.168.1.80:789}'"; exec ($output); ?>
When running on the server the following code, it works perfectly:

Code: Select all

php stream.php
When running it on a remote PC using a webbrowser VLC does start, but it doesn't stream anything

Code: Select all

http://192.168.1.80/stream.php
Anyone? I have similar scripts invoking VLC as Daemon, so I don't think it has to do anything with rights.

osmanosman
Blank Cone
Blank Cone
Posts: 32
Joined: 25 Oct 2006 12:47

Postby osmanosman » 15 Jan 2007 10:47

Do you check your php files permisions?

lokrain
New Cone
New Cone
Posts: 6
Joined: 09 Feb 2007 17:09

File Permissions

Postby lokrain » 09 Feb 2007 17:14

Solution:

Code: Select all

chmod +s /usr/bin/vlc
Note: Everything must be fine now. Not sure if the ' and " symbols will be executed correctly. I have problem with that, but since I start VLC as a daemon I cannot get any error output using proc_open() and stream_get_contents() functions.

muse
Blank Cone
Blank Cone
Posts: 30
Joined: 18 Jul 2006 10:31
VLC version: 0.86c
Operating System: Linux
Location: Italy
Contact:

Postby muse » 14 Feb 2007 16:48

i have the same problem, i tried to set chmod +s /usr/bin/vlc as wrote in the previous reply but it did not work.
I tried both `` (backtics) and exec() with follows syntax:


<?php
....

$command='/usr/bin/vlc --daemon -I telnet --color --ttl 6 dvb: --sout-all --dvb-adapter=0 --dvb-srate=8000 --dvb-budget-mode --dvb-frequency=698000000 --dvb-bandwidth=8 --dvb-hierarchy=0 --dvb-guard=32 --dvb-transmission=8 --sout \'#duplicate{dst=std{access=udp,mux=ts,url=228.228.228.228:1111,sap,name="RaiUno"},select="program=3401",dst=std{access=udp,mux=ts,url=228.228.228.228:2222,sap,name="RaiDue"},select="program=3402",dst=std{access=udp,mux=ts,url=228.228.228.228:3333,sap,name="RaiTre"},select="program=3403"}\'';

exec($command);

....

?>


<?php
....

$command='/usr/bin/vlc --daemon -I telnet --color --ttl 6 dvb: --sout-all --dvb-adapter=0 --dvb-srate=8000 --dvb-budget-mode --dvb-frequency=698000000 --dvb-bandwidth=8 --dvb-hierarchy=0 --dvb-guard=32 --dvb-transmission=8 --sout \'#duplicate{dst=std{access=udp,mux=ts,url=228.228.228.228:1111,sap,name="RaiUno"},select="program=3401",dst=std{access=udp,mux=ts,url=228.228.228.228:2222,sap,name="RaiDue"},select="program=3402",dst=std{access=udp,mux=ts,url=228.228.228.228:3333,sap,name="RaiTre"},select="program=3403"}\'';

$start=`$command`;

....
?>

I think there could be a problem about the lenght of the command or its syntax because using a shorter command it works :
...
$command = 'vlc --intf ncurses -I telnet --rtsp-host '.$ip.':'.$serverport.' & > vlc.log';
$response=`$command`;
...

if i run 'top' on the server after have called this php code, it shows :

USER ................................. COMMAND
www-data vlc --intf ...






:?: :?: :?:
The only winning move is not to play

bXn
Blank Cone
Blank Cone
Posts: 46
Joined: 08 Jun 2005 09:14

Postby bXn » 29 Mar 2007 10:00

did you checked that www-data user has rights to access /dev/dvb/adaptorx directory ?
Image
Image

muse
Blank Cone
Blank Cone
Posts: 30
Joined: 18 Jul 2006 10:31
VLC version: 0.86c
Operating System: Linux
Location: Italy
Contact:

Postby muse » 30 Mar 2007 11:04

did you checked that www-data user has rights to access /dev/dvb/adaptorx directory ?


drwxr-xr-x 2 0 0 140 Mar 23 19:33 adapter0

:roll:


chmod +r /dev/dvb/adapter0

... i'm going to retry...
brb
The only winning move is not to play

bXn
Blank Cone
Blank Cone
Posts: 46
Joined: 08 Jun 2005 09:14

Postby bXn » 30 Mar 2007 13:23

When I had this problem, I was able to find error messages in the apache log file saying permission denied
Image
Image

muse
Blank Cone
Blank Cone
Posts: 30
Joined: 18 Jul 2006 10:31
VLC version: 0.86c
Operating System: Linux
Location: Italy
Contact:

Postby muse » 30 Mar 2007 13:46

When I had this problem, I was able to find error messages in the apache log file saying permission denied
another issue....

when i run vlc from php with

$command = 'vlc --intf ncurses -I telnet --rtsp-host '.$ip.':'.$serverport;
$wait=`sleep 5`;^M
$run = `$command`;

or

exec($command)

or

system($command)

it runs two processes....

ps -A
...
13623 ? 00:00:00 sshd
13625 pts/3 00:00:00 bash
14174 ? 00:00:00 vlc
14175 ? 00:00:00 vlc
...

WTF ???
:shock:
The only winning move is not to play

muse
Blank Cone
Blank Cone
Posts: 30
Joined: 18 Jul 2006 10:31
VLC version: 0.86c
Operating System: Linux
Location: Italy
Contact:

Postby muse » 30 Mar 2007 14:32

When I had this problem, I was able to find error messages in the apache log file saying permission denied
yep...

:/var/log/apache2# cat error.log|grep vlc
vlc(10738): Operation not permitted
vlc: no process killed
vlc(10738): Operation not permitted
vlc: no process killed
vlc(13008): Operation not permitted
vlc: no process killed
vlc(13008): Operation not permitted
vlc: no process killed
vlc: no process killed
vlc(13641): Operation not permitted
vlc: no process killed
vlc: no process killed


...


/var/log/apache2# cat error.log|grep dvb
[00000294] [Media: 698000000] dvb access error: FrontEndOpen: opening device failed (Permission denied)
[00000281] [Media: 698000000] main input error: no suitable access module for `dvb/ts:adapter=0:frequency=698000000:inversion=0:bandwidth=8:code-rate-hp=2:code-rate-lp=0:modulation=64:transmission=8:guard=32:budget-mode=1'
using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'
main:1884: FATAL: failed to open '/dev/dvb/adapter0/frontend0': 13 Permission denied
using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'
main:1884: FATAL: failed to open '/dev/dvb/adapter0/frontend0': 13 Permission denied
using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'
main:1884: FATAL: failed to open '/dev/dvb/adapter0/frontend0': 13 Permission denied
using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'
main:1884: FATAL: failed to open '/dev/dvb/adapter0/frontend0': 13 Permission denied
using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'
main:1884: FATAL: failed to open '/dev/dvb/adapter0/frontend0': 13 Permission denied
[00000302] [Media: 754000000] dvb access error: FrontEndOpen: opening device failed (Permission denied)
[00000281] [Media: 754000000] main input error: no suitable access module for `dvb/ts:adapter=0:frequency=754000000:inversion=0:bandwidth=8:code-rate-hp=2:code-rate-lp=0:modulation=64:transmission=8:guard=32:budget-mode=1'
[00000330] [Media: 754000000] dvb access error: FrontEndOpen: opening device failed (Permission denied)
....

now i'm going to try to set the permission... i just have to find the location of php daemon in debian ...
The only winning move is not to play

bXn
Blank Cone
Blank Cone
Posts: 46
Joined: 08 Jun 2005 09:14

Postby bXn » 30 Mar 2007 16:23

I am also using Debian.
In my case, the PHP page is called by the www-data user and so
this user needs also the rights to access the dvb devices tree.
Image
Image

muse
Blank Cone
Blank Cone
Posts: 30
Joined: 18 Jul 2006 10:31
VLC version: 0.86c
Operating System: Linux
Location: Italy
Contact:

Postby muse » 30 Mar 2007 16:49

now www-data has the access to the dvb interface..

i have to resolve the problem of the twice vlc process running....

i'm going slightly mad...
The only winning move is not to play

bXn
Blank Cone
Blank Cone
Posts: 46
Joined: 08 Jun 2005 09:14

Postby bXn » 30 Mar 2007 17:04

do you have the 2 instances even if you are not launching the rc interface ?

by the way, if you want, just drop your script here and I will try it out on my machine.

may be coud you try a

Code: Select all

ps -eaf | grep vlc
to know if the two instances are using the same command line parameters ?
Image
Image

muse
Blank Cone
Blank Cone
Posts: 30
Joined: 18 Jul 2006 10:31
VLC version: 0.86c
Operating System: Linux
Location: Italy
Contact:

Postby muse » 30 Mar 2007 17:14

do you have the 2 instances even if you are not launching the rc interface ?
... yes i do... :(

$command = '/usr/bin/vlc --daemon -I telnet --rtsp-host '.$ip.':'.$serverport;
$wait=`sleep 5`;^M
system($command);

from 'top' i see that www-data has launched only one of these two processes...
:roll:

if i launch the same command form the shell, instead of php, it runs only one process... as it should be...

these are the mysteries of life..
The only winning move is not to play

bXn
Blank Cone
Blank Cone
Posts: 46
Joined: 08 Jun 2005 09:14

Postby bXn » 30 Mar 2007 17:20

could you try without the --daemon parameter
Image
Image

muse
Blank Cone
Blank Cone
Posts: 30
Joined: 18 Jul 2006 10:31
VLC version: 0.86c
Operating System: Linux
Location: Italy
Contact:

Postby muse » 30 Mar 2007 17:36

i tried also with these simply php pages...

with
<?
system('/usr/bin/vlc -I telnet --rtsp-host 131.114.53.225:5554');
?>

it runs 2 processess...

with
<?
system('/usr/bin/vlc --rtsp-host 131.114.53.225:5554');
?>

it runs no processes..

with

<?
system('/usr/bin/vlc');
?>

it runs no processes

....

log file :

VLC media player 0.8.5 Janus
starting VLC root wrapper... using UID 33 (www-data)
[00000278] skins2 interface error: Cannot open display
[00000278] skins2 interface error: cannot initialize OSFactory
Error: Unable to initialize gtk, is DISPLAY set properly?
VLC media player 0.8.5 Janus
starting VLC root wrapper... using UID 33 (www-data)
[00000278] skins2 interface error: Cannot open display
[00000278] skins2 interface error: cannot initialize OSFactory
Error: Unable to initialize gtk, is DISPLAY set properly?
VLC media player 0.8.5 Janus
starting VLC root wrapper... using UID 33 (www-data)
[00000278] skins2 interface error: Cannot open display
[00000278] skins2 interface error: cannot initialize OSFactory
Error: Unable to initialize gtk, is DISPLAY set properly?


ok... right.. the gui ..

...so i tried

<?
system('/usr/bin/vlc --intf telnet');
?>

and he said :

escher:/var/log/apache2# ps -A|grep vlc
17849 ? 00:00:00 vlc
17850 ? 00:00:00 vlc
.. 2 fu***d processes :)

:)

:)
The only winning move is not to play

bXn
Blank Cone
Blank Cone
Posts: 46
Joined: 08 Jun 2005 09:14

Postby bXn » 30 Mar 2007 17:44

I am using the dummy interface, any try ?
Image
Image

muse
Blank Cone
Blank Cone
Posts: 30
Joined: 18 Jul 2006 10:31
VLC version: 0.86c
Operating System: Linux
Location: Italy
Contact:

Postby muse » 03 Apr 2007 13:23

One process is launched as root and the other one as www-data user.

:shock:

php is running as root...

maybe i have to disable the secure_mode on debian ?

or i can try to set /usr/bin/vlc executable only by root...
The only winning move is not to play

lokrain
New Cone
New Cone
Posts: 6
Joined: 09 Feb 2007 17:09

Postby lokrain » 18 Apr 2007 10:22

Nice idea muse, vlc to be started only by root, but I think this will not be a solution. Some more deep understanding is needed here. Perhaps the solution will come with how the vlc process is forked.

bXn
Blank Cone
Blank Cone
Posts: 46
Joined: 08 Jun 2005 09:14

Postby bXn » 26 Apr 2007 13:35

Nice idea muse, vlc to be started only by root, but I think this will not be a solution. Some more deep understanding is needed here. Perhaps the solution will come with how the vlc process is forked.
if vlc is not launched by root but by an another user, then this user
shoudl have the appropriate rights to access /dev/dvb/* directory no ?
Image
Image

muse
Blank Cone
Blank Cone
Posts: 30
Joined: 18 Jul 2006 10:31
VLC version: 0.86c
Operating System: Linux
Location: Italy
Contact:

Postby muse » 26 Apr 2007 14:26

Nice idea muse, vlc to be started only by root, but I think this will not be a solution. Some more deep understanding is needed here. Perhaps the solution will come with how the vlc process is forked.
if vlc is not launched by root but by an another user, then this user
shoudl have the appropriate rights to access /dev/dvb/* directory no ?
i fixed the problem about the appropriate rights to access /dev/dvb/* directory reading the error.log file of apache.. but this is a different issue..
The only winning move is not to play

bXn
Blank Cone
Blank Cone
Posts: 46
Joined: 08 Jun 2005 09:14

Postby bXn » 26 Apr 2007 16:57

but this is a different issue..
sure ;o)
regarding memory consumption, do they consume the same amount
of memory (and cpu ) ?
Image
Image

muse
Blank Cone
Blank Cone
Posts: 30
Joined: 18 Jul 2006 10:31
VLC version: 0.86c
Operating System: Linux
Location: Italy
Contact:

Postby muse » 26 Apr 2007 17:19

but this is a different issue..
sure ;o)
regarding memory consumption, do they consume the same amount
of memory (and cpu ) ?
One process seems like freeze (0 cpu, 0 memory) and the other one use about 1% of cpu time .. but both processes don't stream ..
The only winning move is not to play

lokrain
New Cone
New Cone
Posts: 6
Joined: 09 Feb 2007 17:09

are you sure?

Postby lokrain » 21 May 2007 15:03

Care about the word fork. Anyway how did you fix the access about /dev/dvb? Can you write complete solution?


Return to “Web and scripting”

Who is online

Users browsing this forum: No registered users and 7 guests