5

I am running uBuntu 12.04.3, 32 bit OS on a 8 CPU, 8GB RAM 64-bit Intel Xeon machine. I have installed all backports as well.

I have this problem which is eating my head for the last 3 days. I created a play.sh file with the following code...

Code:

#! /bin/sh 

vlc -vvv sasural.ts

Where sasural.ts is a video file that resides under home and in the same level as Apache. I am invoking the .sh file by using the following PHP code...

Code:

shell_exec('play.sh');

I also tried both the exec() / system() methods to invoke the .sh file.

Whenever I do so, I get the following message...

VLC media player 2.2.0-git Weatherwax Command Line Interface initialized. Type `help' for help. > Shutting down.

play.sh works if I execute it from the terminal command prompt outside of the PHP code. I guess I am doing something wrong when I invoke it from within PHP.

I have performed the following tasks...

  1. Given Apache Root Access
  2. Linked all folders to Apache
8
  • What for is -vvv option? I use VLC media player 2.0.8 Twoflower and I have no problem. Aug 26, 2013 at 15:10
  • 1
    Try hardcoding the path to the shell script - it's possible that while it's in the same directory as apache, it isn't in the same directory as where the PHP interpreter runs from
    – jackweirdy
    Aug 26, 2013 at 15:34
  • 1
    @RaduRădeanu: I cannot use any VLC version under 2.1. My problem is that I have to get the media files from a server which only accepts https:// and any version under 2.1 does not allow manual acceptance / storage of certificates. Try navigating to 122.160.220.83/bharti/bharti/PREVIEW/sasural.ts and let me know if it shows on your VLC. Aug 26, 2013 at 17:35
  • No, it shows only strange characters. Aug 26, 2013 at 17:47
  • 1
    Double checking - where are you expecting VLC to open? On the client or on the server? If you want it on the client, you won't be able to solve this with PHP
    – jackweirdy
    Aug 29, 2013 at 18:26

3 Answers 3

4

Done it :)

That was fun :D

prerequisites: vlc must already be running fifo file must exist The below will set this up:

mkfifo /tmp/vlcfifo
chmod a+rw /tmp/vlcfifo
tail -f /tmp/vlcfifo | nohup vlc --intf rc &

in the php file:

<?php
passthru('echo "add /path/to/video.avi" | tee /tmp/vlcfifo');
?>

Give that a try :)

1
  • I will try this out tomorrow morning! I hope this will work for the headless noX (Non GUI) version of VLC. Aug 28, 2013 at 21:10
2

In your script, before you launch vlc, have the line: export DISPLAY=:0

This should launch it in your primary X session, assuming the webserver is running on the same box as your X session.

You will also need to do something with sound if you require it. Like a remote ALSA or Pulseaudio server.

3
  • Assuming there is an X session on the system. This might be a server without a GUI.
    – Thomas Ward
    Aug 27, 2013 at 20:32
  • Hey Thanks! i will try this out first thing tomorrow! I really - really hope this works! By the way this IS a headless (Non-GUI) server. Which also basically means that I have the noX version of VLC installed on it. Do you think this still could be the solutions? Aug 28, 2013 at 21:07
  • Using a headless server is fine, but you do need the basic X libs and the X version of VLC. The DISPLAY environment variable is telling you which X server to connect to. It's an easy way to display any X application on different X displays, and it doesn't have to be the same host either. I do this through SSH X11 forwarding all the time. I guess knowing more on what you are attempting to do would help, I just have picked up, "launching the GUI version of VLC through an Apache (I assume) PHP page." Aug 29, 2013 at 17:48
1

Gentlemen,

I have been able to solve this issue by using the following steps...

  • Install vlc nox version
  • In the PHP file: echo shell_exec("sh /var/www/play1.sh");

  • In the play1.sh file: #!/bin/sh vlc -Idummy /var/www/media.ts --sout '#standard{access=http,mux=ts,dst=:1935/}'

  • Invoke the PHP file via a browser and VLC will start streaming to port 1935

To access the file from the client end...

1) Point VLC or any media player to the URL + Port. Ex. http://www.something.com:1935 2) The client player will start to receive the file and play it back.

Now the next step is to enable this file on demand. Will post how I did that as well so stay tuned!!

Thank you everybody who have helped me in solving this problem. I have added +reps wherever it was possible.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .