Skip to content

Commit

Permalink
Fix webcam to work with /boot/firmware/octopi.txt path #823 guysoft/C…
Browse files Browse the repository at this point in the history
  • Loading branch information
guysoft committed Jul 16, 2024
1 parent 5809c96 commit 370549c
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 18 deletions.
6 changes: 5 additions & 1 deletion src/modules/octopi/filesystem/home/root/bin/streamer_select
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
# Exit on any error.
set -e

CONFIG_FILE=/boot/firmware/octopi.txt
# Fallback for older images
if [ ! -f "${CONFIG_FILE}" ] && [ -f "/boot/octopi.txt" ]; then
CONFIG_FILE=/boot/octopi.txt
fi
MJPEG_TYPE=mjpeg
HLS_TYPE=hls
MJPEG_SERVICE=webcamd.service
Expand All @@ -29,4 +33,4 @@ elif [ "${camera_streamer}" = "${HLS_TYPE}" ]; then
else
echo "Streamer type '${camera_streamer}' is not supported."
exit 1
fi
fi
34 changes: 20 additions & 14 deletions src/modules/octopi/filesystem/home/root/bin/webcamd
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
#!/bin/bash

########################################################################
### DO NOT EDIT THIS FILE TO CHANGE THE CONFIG!!! ###
### ---------------------------------------------------------------- ###
### There is no need to edit this file for changing resolution, ###
### frame rates or any other mjpg-streamer parameters. Please edit ###
### /boot/octopi.txt instead - that's what it's there for! You can ###
### even do this with your Pi powered down by directly accessing the ###
### file when using the SD card as thumb drive in your regular ###
### computer. ###
########################################################################
###############################################################################
### DO NOT EDIT THIS FILE TO CHANGE THE CONFIG!!! ###
### ----------------------------------------------------------------------- ###
### There is no need to edit this file for changing resolution, ###
### frame rates or any other mjpg-streamer parameters. Please edit ###
### /boot/firmware/octopi.txt instead - that's what it's there for! You can ###
### even do this with your Pi powered down by directly accessing the ###
### file when using the SD card as thumb drive in your regular ###
### computer. ###
###############################################################################

MJPGSTREAMER_HOME=/opt/mjpg-streamer
MJPGSTREAMER_INPUT_USB="input_uvc.so"
MJPGSTREAMER_INPUT_RASPICAM="input_raspicam.so"

CONFIG_FILE=/boot/firmware/octopi.txt
# Fallback for older images
if [ ! -f "${CONFIG_FILE}" ] && [ -f "/boot/octopi.txt" ]; then
CONFIG_FILE=/boot/octopi.txt
fi

brokenfps_usb_devices=("046d:082b" "1908:2310" "0458:708c" "0458:6006" "1e4e:0102" "0471:0311" "038f:6001" "046d:0804" "046d:0994" "0ac8:3450")

config_dir="/boot/octopi.conf.d"
config_dir="${CONFIG_FILE}/octopi.conf.d"

echo "Starting up webcamDaemon..."
echo ""

cfg_files=()
cfg_files+=/boot/octopi.txt
cfg_files+="${CONFIG_FILE}"
if [[ -d ${config_dir} ]]; then
cfg_files+=( `ls ${config_dir}/*.txt` )
fi
Expand All @@ -41,7 +47,7 @@ array_assigned_device=()

echo "--- Configuration: ----------------------------"
for cfg_file in ${cfg_files[@]}; do
# init configuration - DO NOT EDIT, USE /boot/octopi.conf.d/*.txt INSTEAD!
# init configuration - DO NOT EDIT, USE /boot/firmware/octopi.conf.d/*.txt INSTEAD!
camera="auto"
camera_usb_options="-r 640x480 -f 10"
camera_raspi_options="-fps 10"
Expand All @@ -54,7 +60,7 @@ for cfg_file in ${cfg_files[@]}; do
fi
usb_options="$camera_usb_options"

# if webcam device is explicitly given in /boot/octopi.txt, save the path of the device
# if webcam device is explicitly given in /boot/firmware/octopi.txt, save the path of the device
# to a variable and remove its parameter from usb_options
extracted_device=`echo $usb_options | sed 's@.*-d \(/dev/\(video[0-9]\+\|v4l/[^ ]*\)\).*@\1@'`
if [ "$extracted_device" != "$usb_options" ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@

. /lib/lsb/init-functions

BOOT_FOLDER=/boot/firmware
# Fallback for older images
if [ ! -f "${CONFIG_FILE}" ] && [ -f "/boot/octopi.txt" ]; then
BOOT_FOLDER=/boot
fi

do_start () {
text_file="/boot/octopi-hostname.txt"
text_file="${BOOT_FOLDER}/octopi-hostname.txt"
if [ ! -f "$text_file" ]
then
exit 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@

. /lib/lsb/init-functions

BOOT_FOLDER=/boot/firmware
# Fallback for older images
if [ ! -f "${CONFIG_FILE}" ] && [ -f "/boot/octopi.txt" ]; then
BOOT_FOLDER=/boot
fi

do_start () {
text_file="/boot/octopi-password.txt"
text_file="${BOOT_FOLDER}/octopi-password.txt"
if [ ! -f "$text_file" ]
then
exit 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/bin/bash
CONFIG_FILE=/boot/firmware/octopi.txt
# Fallback for older images
if [ ! -f "${CONFIG_FILE}" ] && [ -f "/boot/octopi.txt" ]; then
CONFIG_FILE=/boot/octopi.txt

source /boot/octopi.txt
source "${CONFIG_FILE}"

if [ $enable_network_monitor == 1 ] && [ "$destination_host" != "" ]; then

Expand Down

0 comments on commit 370549c

Please sign in to comment.