2016-06-26 4 views
0

저는 사진 부스를 만드는 프로젝트를 진행하고 있습니다. 내가 쓴 웹 페이지를 보여주는 카메라 (캐논 550d)와 터치 스크린 PC (우분투 실행)가있다.PHP 명령으로 MPlayer를 시작하십시오.

gphoto2을 사용하여 웹 페이지 내에서 exec()을 사용하여 내 DSLR을 제어하면 사진을 쉽게 찍을 수 있습니다.

제 문제는 사람들이 사진을 찍기 전에 카메라에서 실시간 미리보기를 보여주고 싶습니다.

#!/bin/bash 
gphoto2 --capture-movie --stdout > fifo.mjpg & mplayer -cache 32 -demuxer 35 -noborder -geometry 50%:100 -ontop 1 fifo.mjpg 

기본적으로 gphoto2 스트림은 다음 MPlayer는을 fifo.mjpg하고 : 지금, 나는 또한 모든의 상단에 남아 경계선 창 내에서 MPlayer는 인스턴스를 엽니 다 준비 스크립트가 코드는 live.sh라는 파일에 그 파일을 재생합니다.

그것은 모두가 잘 작동하고 내가 터미널에서 이것을 실행 잘 때 나는 PHP

exec("bash live.sh", $output); 

에서 같은 명령을 실행하면

bash live.sh 

그것은 작동하지 않습니다에서보세요 이 두 환경에서 실행했을 때 얻는 결과

터미널에서 실행 중 (이 작업) :

MPlayer 1.2.1 (Debian), built with gcc-5.3.1 (C) 2000-2016 MPlayer Team 
mplayer: could not connect to socket 
mplayer: No such file or directory 
Failed to open LIRC support. You will not be able to use your remote control. 

Playing 1. 
File not found: '1' 
Failed to open 1. 


Playing fifo.mjpg. 


libavformat version 56.40.101 (external) 
Capturing preview frames as movie to 'stdout'. Press Ctrl-C to abort. 

*** Error ***    
An error occurred in the io-library ('Could not claim the USB device'): Could not claim interface 0 (Device or resource busy). Make sure no other program (gvfs-gphoto2-volume-monitor) or kernel module (such as sdc2xx, stv680, spca50x) is using the device and you have read/write access to the device. 
ERROR: Movie capture error... Exiting. 
Movie capture finished (0 frames) 
libavformat file format detected. 
Cannot seek backward in linear streams! 
Seek failed 
[mjpeg @ 0x7f9cffecb540]Found EOI before any SOF, ignoring 
[mjpeg @ 0x7f9cffecb540]Changeing bps to 8 
[lavf] stream 0: video (mjpeg), -vid 0 
VIDEO: [MJPG] 1056x704 0bpp 25.000 fps 0.0 kbps (0.0 kbyte/s) 
Load subtitles in ./ 
Failed to open VDPAU backend libvdpau_va_gl.so: cannot open shared object file: No such file or directory 
[vdpau] Error when calling vdp_device_create_x11: 1 
========================================================================== 
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family 
libavcodec version 56.60.100 (external) 
Selected video codec: [ffmjpeg] vfm: ffmpeg (FFmpeg MJPEG) 
========================================================================== 
Audio: no sound 
Starting playback... 
[mjpeg @ 0x7f9cffecb540]Found EOI before any SOF, ignoring 
[mjpeg @ 0x7f9cffecb540]Changeing bps to 8 
Could not find matching colorspace - retrying with -vf scale... 
Opening video filter: [scale] 
Movie-Aspect is undefined - no prescaling applied. 
[swscaler @ 0x7f9d00c36fa0]bicubic scaler, from yuv422p to yuyv422 using  MMXEXT 
[swscaler @ 0x7f9d00c36fa0]using unscaled yuv422p -> yuyv422 special converter 
VO: [xv] 1056x704 => 1056x704 Packed YUY2 
Movie-Aspect is undefined - no prescaling applied. 
VO: [xv] 1056x704 => 1056x704 Packed YUY2 
V: 0.5 0/ 0 37% 14% 0.0% 0 0 50% 

MPlayer interrupted by signal 2 in module: enable_cache 



MPlayer interrupted by signal 2 in module: video_read_frame 
[mjpeg @ 0x7f9cffecb540]overread 8 
[mjpeg @ 0x7f9cffecb540]EOI missing, emulating 
V: 0.6 0/ 0 36% 13% 0.0% 0 0 50% 

Exiting... (Quit) 

모든 오류에도 불구하고 모든 것이 놀랍도록 잘 작동합니다.

array(16) { 
    [0]=> 
    string(71) "MPlayer 1.2.1 (Debian), built with gcc-5.3.1 (C) 2000-2016 MPlayer Team" 
    [1]=> 
    string(39) "Terminal type `unknown' is not defined." 
    [2]=> 
    string(0) "" 
    [3]=> 
    string(10) "Playing 1." 
    [4]=> 
    string(0) "" 
    [5]=> 
    string(0) "" 
    [6]=> 
    string(18) "Playing fifo.mjpg." 
    [7]=> 
    string(29) " 
    Cache fill: 0.00% (0 bytes)" 
    [8]=> 
    string(0) "" 
    [9]=> 
    string(40) "libavformat version 56.40.101 (external)" 
    [10]=> 
    string(33) "libavformat file format detected." 
    [11]=> 
    string(39) "Cannot seek backward in linear streams!" 
    [12]=> 
    string(42) "[mjpeg @ 0x7fb771bec540]Changeing bps to 8" 
    [13]=> 
    string(38) "[lavf] stream 0: video (mjpeg), -vid 0" 
    [14]=> 
    string(69) "VIDEO: [MJPG] 1056x704 0bpp 25.000 fps 0.0 kbps (0.0 kbyte/s)" 
    [15]=> 
    string(20) "Load subtitles in ./" 
} 

사람이 일을하는 방법에 대한 아이디어를 가지고 있다면, 내가 될 것입니다 :

은 (이 작동하지 않습니다) PHP의 간부 인()에서 실행할 때 내가 얻을 출력 매우 고맙습니다.

감사합니다.

답변

0

execpopen으로 바꾸고 배경을 스크립트 호출로 지정하십시오.

pclose(popen("bash live.sh > /dev/null &", 'r')); 

이렇게하면 코드가 PHP에서 분리 된 쉘에서 실행됩니다. 이것은 MPlayer가 작동하는 것을 도울 것입니다.

+0

방금 ​​시도했지만 아무 것도 없습니다. –

+0

터미널에서 이것을 실행 해 보았습니다 : php -r 'pclose (popen ("bash live.sh> /var/www/html/booth/log.txt", "r"));' 그리고 작동합니다. –

+0

작동합니까 아니면 작동하지 않습니까? bash 스크립트 호출''/ usr/bin/bash/path/to/live.sh'에 전체 경로를 추가해보십시오. – cb0