0

Trying to initiate a mpv video play on a linux server with php exec command from a remote machine. Only able to get audio working. Getting error for video.

code on php file:

$cmd = "DISPLAY=:1 mpv video/test.mp4 --ao=alsa:device=[hw:1]";
$out = shell_exec($cmd);

output:

Playing: video/test.mp4
 (+) Video --vid=1 (*) (h264)
 (+) Audio --aid=1 --alang=und (*) (aac)
No protocol specified
[vo/vdpau/x11] couldn't open the X11 display (:1)!
Error opening/initializing the selected video_out (-vo) device.
Video: no video
No protocol specified
xcb_connection_has_error() returned true
Home directory not accessible: Permission denied
W: [pulseaudio] core-util.c: Failed to open configuration file '/root/.config/pulse//daemon.conf': Permission denied
W: [pulseaudio] daemon-conf.c: Failed to open configuration file: Permission denied
AO: [alsa] 44100Hz stereo 2ch s32
A: 00:00:23 / 00:04:33 (8%)

As a root user from php interactive shell able to play the video without any issues. But as a www-data user from remote terminal getting problem with video play. Any solutions to set up permissions for video play?. Thanks in advance

Sevon
  • 1
  • 2
  • You probably set it up as `root` user so it reads a conf file from `/root/.config/pulse//daemon.conf` which a normal user doesn't have access to. – iamauser Jan 13 '18 at 15:05
  • Thanks. got the solution. added permission for user in existing x server by exec xhost +local:www-data. – Sevon Jan 18 '18 at 05:48

0 Answers0