Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
$newConfig['login_password'] = NULL;
}

if ($newConfig['preview_mode'] != 'device_cam') {
if ($newConfig['preview_mode'] != 'device_cam' && $newConfig['preview_mode'] != 'gphoto') {
$newConfig['previewCamTakesPic'] = false;
}

Expand Down
37 changes: 37 additions & 0 deletions api/takeVideo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?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" ) {
$cmd = sprintf($config['preview']['cmd']);
$pid = exec($cmd, $out);
sleep(3);
die(json_encode([
'isRunning' => isRunning($pid),
'pid' => $pid - 1
]));
} elseif($_POST['play'] === "false") {
$killcmd = sprintf($config['preview']['killcmd']);
exec($killcmd);
die(json_encode([
'isRunning' => isRunning($_POST['pid']),
'pid' => $_POST['pid']
]));
}
5 changes: 4 additions & 1 deletion config/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@

// P R E V I E W
// Please read https://github.com/andi34/photobooth/wiki/FAQ#how-to-use-a-live-stream-as-background-at-countdown
// possible preview_mode values: none, device_cam, url
// possible preview_mode values: none, device_cam, url, gphoto
$config['preview_mode'] = 'none';
$config['preview_gphoto_bsm'] = true;
$config['previewCamTakesPic'] = false;
$config['previewCamFlipHorizontal'] = true;
// possible ipCamPreviewRotation values: '0deg', '90deg', -90deg', '180deg', '45deg', '-45deg'
Expand Down Expand Up @@ -229,6 +230,8 @@
$config['print']['msg'] = null;
$config['exiftool']['cmd'] = null;
$config['exiftool']['msg'] = null;
$config['preview']['cmd'] = null;
$config['preview']['killcmd'] = null;


// R E M O T E B U Z Z E R
Expand Down
16 changes: 16 additions & 0 deletions faq/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,22 @@ There's different ways depending on your needs and personal setup:
- Capture pictures via `raspistill` won't work if motion is installed!
- Requires Photobooth v2.2.1 or later!

3. A device independent preview can also be done using the video mode of your DSLR (Linux only):
- install all dependencies `sudo apt install ffmpeg v4l2loopback-dkms -y`
- create a virtual webcam `modprobe v4l2loopback exclusive_caps=1 card_label="GPhoto2 Webcam"`
- `/dev/video0` is used by default, you can use `v42l-ctl --list-devices` to check which `/dev/*` is the correct one:
If it doesn't match the default setup you need to adjust the `Command to generate a live preview` inside the admin panel!
- Give permissions to /dev/video* `sudo gpasswd -a www-data video` (this was done automatically if you used the installation script) and reboot once
- Admin panel config *"Preview mode"*: `from gphoto2`

**Note**
- Requires Photobooth v2.11.0 or later!
- There's a delay of about 3 seconds until the preview starts, to avoid that disable the `Battery saving mode on gphoto2 live preview` option to generate a preview in background. **This results in a high battery usage and also a general slowdown.**
- Sometimes Chromium doesn't detect the V4l2 camera launch from php: you need to run `sudo gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video0` from terminal first and load Chromium a first time with a webpage asking for the camera.
- Chromium sometimes has trouble, if there is another webcam like `bcm2835-isp`, it will take it by default instead. Disable other webcams, e.g. `rmmod bcm2835-isp`.
- Make sure the countdown is long enough to start the preview and free gphoto2 at the end of the countdown to be able to take a picture (2 seconds before the countdown ends).
- For best user experience the countdown should be set at least to 8 seconds.

<hr>

### Can I use a live stream as background?
Expand Down
1 change: 1 addition & 0 deletions install-raspbian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ fi
info "### Setting permissions."
chown -R www-data:www-data $INSTALLFOLDERPATH
gpasswd -a www-data plugdev
gpasswd -a www-data video

if [ -f "/usr/lib/gvfs/gvfs-gphoto2-volume-monitor" ]; then
info "### Disabling camera automount."
Expand Down
10 changes: 10 additions & 0 deletions lib/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
'exiftool' => [
'cmd' => '',
'msg' => '',
],
'preview' => [
'cmd' => '',
'killcmd' => '',
]
],
'linux' => [
Expand All @@ -32,6 +36,10 @@
'exiftool' => [
'cmd' => 'exiftool -overwrite_original -TagsFromFile %s %s',
'msg' => '',
],
'preview' => [
'cmd' => 'gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video0 > /dev/null 2>&1 & echo $!',
'killcmd' => 'killall gphoto2 && sleep 1',
]
],
];
Expand Down Expand Up @@ -65,6 +73,8 @@
$config['print']['msg'] = $cmds[$os]['print']['msg'];
$config['exiftool']['cmd'] = $cmds[$os]['exiftool']['cmd'];
$config['exiftool']['msg'] = $cmds[$os]['exiftool']['msg'];
$config['preview']['cmd'] = $cmds[$os]['preview']['cmd'];
$config['preview']['killcmd'] = $cmds[$os]['preview']['killcmd'];

$config['collage_limit'] = 4;

Expand Down
20 changes: 19 additions & 1 deletion lib/configsetup.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,16 @@
'options' => [
'none' => 'None',
'device_cam' => 'from device cam',
'url' => 'from URL'
'url' => 'from URL',
'gphoto' => 'from gphoto2'
],
'value' => $config['preview_mode']
],
'preview_gphoto_bsm' => [
'type' => 'checkbox',
'name' => 'preview_gphoto_bsm',
'value' => $config['preview_gphoto_bsm']
],
'previewCamTakesPic' => [
'type' => 'checkbox',
'name' => 'previewCamTakesPic',
Expand Down Expand Up @@ -1063,6 +1069,18 @@
'placeholder' => 'exiftool_msg',
'name' => 'exiftool[msg]',
'value' => htmlentities($config['exiftool']['msg'])
],
'preview_cmd' => [
'type' => 'input',
'placeholder' => 'preview_cmd',
'name' => 'preview[cmd]',
'value' => htmlentities($config['preview']['cmd'])
],
'preview_killcmd' => [
'type' => 'input',
'placeholder' => 'preview_killcmd',
'name' => 'preview[killcmd]',
'value' => htmlentities($config['preview']['killcmd'])
]
],
'remotebuzzer' => [
Expand Down
17 changes: 17 additions & 0 deletions manual/faq.html
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,23 @@ <h3>How to use a live stream as background at countdown?</h3>
<ul><li>Do NOT enable <em>"Device cam takes picture"</em> in admin panel config!</li>
<li>Capture pictures via <code>raspistill</code> won't work if motion is installed!</li>
<li>Requires Photobooth v2.2.1 or later!</li></ul></li>
<li><p>A device independent preview can also be done using the video mode of your DSLR (Linux only):</p>

<ul><li>install all dependencies <code>sudo apt install ffmpeg v4l2loopback-dkms -y</code></li>
<li>create a virtual webcam <code>modprobe v4l2loopback exclusive_caps=1 card_label="GPhoto2 Webcam"</code>
<ul><li><code>/dev/video0</code> is used by default, you can use <code>v42l-ctl --list-devices</code> to check which <code>/dev/*</code> is the correct one: <br />
If it doesn't match the default setup you need to adjust the <code>Command to generate a live preview</code> inside the admin panel!</li></ul></li>
<li>Give permissions to /dev/video* <code>sudo gpasswd -a www-data video</code> (this was done automatically if you used the installation script) and reboot once</li>
<li>Admin panel config <em>"Preview mode"</em>: <code>from gphoto2</code></li></ul>

<p><strong>Note</strong></p>

<ul><li>Requires Photobooth v2.11.0 or later!</li>
<li>There's a delay of about 3 seconds until the preview starts, to avoid that disable the <code>Battery saving mode on gphoto2 live preview</code> option to generate a preview in background. <strong>This results in a high battery usage and also a general slowdown.</strong></li>
<li>Sometimes Chromium doesn't detect the V4l2 camera launch from php: you need to run <code>sudo gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video0</code> from terminal first and load Chromium a first time with a webpage asking for the camera.</li>
<li>Chromium sometimes has trouble, if there is another webcam like <code>bcm2835-isp</code>, it will take it by default instead. Disable other webcams, e.g. <code>rmmod bcm2835-isp</code>.</li>
<li>Make sure the countdown is long enough to start the preview and free gphoto2 at the end of the countdown to be able to take a picture (2 seconds before the countdown ends).
<ul><li>For best user experience the countdown should be set at least to 8 seconds.</li></ul></li></ul></li>
</ol>

<hr>
Expand Down
6 changes: 6 additions & 0 deletions resources/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
"commands": "Commands",
"commands_exiftool_cmd": "EXIFtool command",
"commands_exiftool_msg": "Success message for EXIF preservation",
"commands_preview_cmd": "Command to generate a live preview",
"commands_preview_killcmd": "Command to kill live preview",
"commands_print_cmd": "Print command",
"commands_print_msg": "Success message for print",
"commands_take_picture_cmd": "Take picture command",
Expand Down Expand Up @@ -121,6 +123,8 @@
"manual_chroma_keying": "If enabled, chromakeying can be accessed from gallery for your pictures.",
"manual_commands_exiftool_cmd": "EXIFtool command line which is executed after taking a picture if \"Preserve EXIF data\" is enabled.",
"manual_commands_exiftool_msg": "Message returned from EXIFtool commandline.",
"manual_commands_preview_cmd": "Command line which is executed to generate a live preview.",
"manual_commands_preview_killcmd": "Command line which is executed to kill the live preview.",
"manual_commands_print_cmd": "Command line which is executed while pressing the \"Print\" button.",
"manual_commands_print_msg": "Message returned from print command.",
"manual_commands_take_picture_cmd": "Command line which is executed while pressing the \"Take Pic\" button. On Linux you can for example use <a href=\"http://www.gphoto.org\" target=\"_blank\">gphoto2</a> to take pictures, on Windows you can use <a href=\"http://digicamcontrol.com\" target=\"_blank\">digiCamControl</a>.",
Expand Down Expand Up @@ -200,6 +204,7 @@
"manual_previewCamFlipHorizontal": "If enabled, preview from device cam is flipped horizontal.",
"manual_previewCamTakesPic": "If enabled, a picture is taken from device cam instead executing the \"Take picture command\". Please note that the resolution depends on the given hight and width because it's acts like taking a screenshot.",
"manual_preview_camera_mode": "Choose between front- or back facing camera mode of your device cam.",
"manual_preview_gphoto_bsm": "If enabled, gphoto2 live preview is started once a photo get triggered. This results in a delay of ~3 seconds until the preview is visible at countdown. If disabled, a preview is generated in background which results in a high battery usage and also a general slowdown.",
"manual_preview_ipCamPreviewRotation": "Choose to rotate the preview from URL.",
"manual_preview_ipCamURL": "CSS style to use a stream from an URL for preview while countdown. <p>Example: <code>url(../img/bg_bluegray.jpg)</code></p>",
"manual_preview_mode": "Choose a live preview mode. By default live preview is disabled, you can choose between a preview at countdown by your device cam and a preview from a URL. Preview \"from device cam\" will always use the camera of the device where Photobooth get opened in a Browser (e.g. on a tablet it will always show the tablet camera while on a smartphone it will always show the smartphone camera instead)! A secure origin or exception is required! You can find out how to set an exception <a href=\"https://medium.com/@Carmichaelize/enabling-the-microphone-camera-in-chrome-for-local-unsecure-origins-9c90c3149339\" target=\"_blank\">here</a>.",
Expand Down Expand Up @@ -289,6 +294,7 @@
"previewCamFlipHorizontal": "Flip image from device cam horizontally",
"previewCamTakesPic": "Device cam takes picture",
"preview_camera_mode": "Camera facing mode",
"preview_gphoto_bsm": "Battery saving mode on gphoto2 live preview",
"preview_ipCamPreviewRotation": "Rotate preview from URL",
"preview_ipCamURL": "Preview-URL",
"preview_mode": "Preview mode",
Expand Down
Loading