forked from andreknieriem/photobooth
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Preview From Photo
- Loading branch information
Showing
2 changed files
with
93 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
header('Content-Type: application/json'); | ||
|
||
require_once('../lib/config.php'); | ||
|
||
function isRunning($pid){ | ||
try{ | ||
$result = shell_exec(sprintf("ps %d", $pid)); | ||
if( count(preg_split("/\n/", $result)) > 2){ | ||
return true; | ||
} | ||
}catch(Exception $e){} | ||
|
||
return false; | ||
} | ||
|
||
if ($_POST['play'] === "true" ) { | ||
$pid = exec('gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video0 > /dev/null 2>&1 & echo $!', $out); | ||
sleep(3); //Allow the Gphoto2 process to start | ||
die(json_encode([ | ||
'isRunning' => isRunning($pid), | ||
'pid' => $pid - 1 | ||
])); | ||
}elseif($_POST['play'] === "false") { | ||
exec('kill -15 '.$_POST['pid']); | ||
die(json_encode([ | ||
'isRunning' => isRunning($_POST['pid']), | ||
'pid' => $_POST['pid'] | ||
])); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 comment
on commit 4b5ba4c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey! I've done some adjustments on your code and merged it into my fork andi34#131
data.style