Page 1 of 1

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

Posted: 14 Jan 2007 16:17
by aux
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.

Posted: 15 Jan 2007 10:47
by osmanosman
Do you check your php files permisions?

File Permissions

Posted: 09 Feb 2007 17:14
by lokrain
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.

Posted: 14 Feb 2007 16:48
by muse
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 ...






:?: :?: :?:

Posted: 29 Mar 2007 10:00
by bXn
did you checked that www-data user has rights to access /dev/dvb/adaptorx directory ?

Posted: 30 Mar 2007 11:04
by muse
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

Posted: 30 Mar 2007 13:23
by bXn
When I had this problem, I was able to find error messages in the apache log file saying permission denied

Posted: 30 Mar 2007 13:46
by muse
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:

Posted: 30 Mar 2007 14:32
by muse
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 ...

Posted: 30 Mar 2007 16:23
by bXn
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.

Posted: 30 Mar 2007 16:49
by muse
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...

Posted: 30 Mar 2007 17:04
by bXn
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 ?

Posted: 30 Mar 2007 17:14
by muse
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..

Posted: 30 Mar 2007 17:20
by bXn
could you try without the --daemon parameter

Posted: 30 Mar 2007 17:36
by muse
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 :)

:)

:)

Posted: 30 Mar 2007 17:44
by bXn
I am using the dummy interface, any try ?

Posted: 03 Apr 2007 13:23
by muse
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...

Posted: 18 Apr 2007 10:22
by lokrain
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.

Posted: 26 Apr 2007 13:35
by bXn
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 ?

Posted: 26 Apr 2007 14:26
by muse
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..

Posted: 26 Apr 2007 16:57
by bXn
but this is a different issue..
sure ;o)
regarding memory consumption, do they consume the same amount
of memory (and cpu ) ?

Posted: 26 Apr 2007 17:19
by muse
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 ..

are you sure?

Posted: 21 May 2007 15:03
by lokrain
Care about the word fork. Anyway how did you fix the access about /dev/dvb? Can you write complete solution?