From a4418ec61f982a395356dda56e4861f7a5a535dd Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 1 Sep 2025 21:22:28 +1200 Subject: [PATCH] config: Add 1 and update 4 files --- .../config/docker-compose.yml | 2 - squashkiwi-streaming/config/mediamtx.yml | 2 + squashkiwi-streaming/config/service.env | 2 + squashkiwi-streaming/install.sh | 10 ++++ squashkiwi-streaming/test-camera.sh | 48 +++++++++++++++++++ 5 files changed, 62 insertions(+), 2 deletions(-) create mode 100755 squashkiwi-streaming/test-camera.sh diff --git a/squashkiwi-streaming/config/docker-compose.yml b/squashkiwi-streaming/config/docker-compose.yml index de82fb7..e8c072e 100644 --- a/squashkiwi-streaming/config/docker-compose.yml +++ b/squashkiwi-streaming/config/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.8' - services: # MediaMTX - RTSP/HLS/WebRTC streaming server mediamtx: diff --git a/squashkiwi-streaming/config/mediamtx.yml b/squashkiwi-streaming/config/mediamtx.yml index f019e11..fa9fcce 100644 --- a/squashkiwi-streaming/config/mediamtx.yml +++ b/squashkiwi-streaming/config/mediamtx.yml @@ -36,6 +36,8 @@ webrtcAllowOrigin: '*' paths: # Main court camera stream court_main: + # Note: Password with special characters should be URL-encoded in service.env + # e.g., ! becomes %21, @ becomes %40, etc. source: rtsp://${CAMERA_USER}:${CAMERA_PASSWORD}@${CAMERA_IP}:${CAMERA_RTSP_PORT}/cam/realmonitor?channel=1&subtype=0 sourceProtocol: tcp sourceOnDemand: no diff --git a/squashkiwi-streaming/config/service.env b/squashkiwi-streaming/config/service.env index fce986b..9953c89 100644 --- a/squashkiwi-streaming/config/service.env +++ b/squashkiwi-streaming/config/service.env @@ -8,6 +8,8 @@ RECORDINGS_FOLDER="/home/dropshell/example-squashkiwi-streaming-recordings" PROJECT_NAME="sk-streaming" # Camera Configuration +# Note: If password contains special characters (! @ # $ & %), they will be automatically URL-encoded +# Or you can manually encode them: ! = %21, @ = %40, # = %23, $ = %24, & = %26 CAMERA_IP=192.168.1.100 CAMERA_USER=admin CAMERA_PASSWORD=changeme diff --git a/squashkiwi-streaming/install.sh b/squashkiwi-streaming/install.sh index d666d69..be7ccbd 100755 --- a/squashkiwi-streaming/install.sh +++ b/squashkiwi-streaming/install.sh @@ -9,10 +9,20 @@ _check_required_env_vars "PROJECT_NAME" "LOCAL_DATA_FOLDER" "CAMERA_IP" "COURT_I # shellcheck disable=SC2046 create_items $(get_squashkiwi_streaming_paths) || _die "Failed to create directories" mkdir -p "${RECORDINGS_FOLDER}" +mkdir -p "${LOCAL_DATA_FOLDER}/config" +mkdir -p "${LOCAL_DATA_FOLDER}/config/overlay" +mkdir -p "${LOCAL_DATA_FOLDER}/config/web" # Copy configuration files cp -r "${SCRIPT_DIR}/config/"* "${LOCAL_DATA_FOLDER}/config/" || _die "Failed to copy config files" +# URL-encode the camera password if it contains special characters +if [[ "${CAMERA_PASSWORD}" == *[!\@\#\$\&\%]* ]]; then + echo "Note: Camera password contains special characters. Encoding for RTSP URL..." + CAMERA_PASSWORD_ENCODED=$(echo -n "${CAMERA_PASSWORD}" | sed 's/!/%21/g; s/@/%40/g; s/#/%23/g; s/\$/%24/g; s/&/%26/g; s/%/%25/g') + export CAMERA_PASSWORD="${CAMERA_PASSWORD_ENCODED}" +fi + # Test Docker _check_docker_installed || _die "Docker test failed, aborting installation..." diff --git a/squashkiwi-streaming/test-camera.sh b/squashkiwi-streaming/test-camera.sh new file mode 100755 index 0000000..05c4c54 --- /dev/null +++ b/squashkiwi-streaming/test-camera.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# Test camera RTSP connection +# shellcheck disable=SC1091 +source "${AGENT_PATH}/common.sh" +_check_required_env_vars "CAMERA_IP" "CAMERA_USER" "CAMERA_PASSWORD" "CAMERA_RTSP_PORT" "LOCAL_DATA_FOLDER" + +echo "Testing camera connection..." +echo "Camera IP: ${CAMERA_IP}" +echo "Camera User: ${CAMERA_USER}" +echo "RTSP Port: ${CAMERA_RTSP_PORT}" + +# URL-encode the password if it contains special characters +ENCODED_PASSWORD=$(echo -n "${CAMERA_PASSWORD}" | sed 's/!/%21/g; s/@/%40/g; s/#/%23/g; s/\$/%24/g; s/&/%26/g') + +RTSP_URL="rtsp://${CAMERA_USER}:${ENCODED_PASSWORD}@${CAMERA_IP}:${CAMERA_RTSP_PORT}/cam/realmonitor?channel=1&subtype=0" + +echo "" +echo "Testing RTSP URL (password hidden): rtsp://${CAMERA_USER}:****@${CAMERA_IP}:${CAMERA_RTSP_PORT}/cam/realmonitor?channel=1&subtype=0" + +# Test with ffprobe +echo "" +echo "Testing with ffprobe..." +docker run --rm --network host \ + linuxserver/ffmpeg:latest \ + ffprobe -v error -show_streams -select_streams v:0 \ + "${RTSP_URL}" 2>&1 | head -20 + +if [ $? -eq 0 ]; then + echo "✓ Camera connection successful!" +else + echo "✗ Camera connection failed" + echo "" + echo "Trying alternative RTSP paths..." + + # Try without subtype parameter + ALT_URL="rtsp://${CAMERA_USER}:${ENCODED_PASSWORD}@${CAMERA_IP}:${CAMERA_RTSP_PORT}/cam/realmonitor?channel=1" + docker run --rm --network host linuxserver/ffmpeg:latest \ + ffprobe -v error "${ALT_URL}" 2>&1 | head -5 + + # Try simple path + SIMPLE_URL="rtsp://${CAMERA_USER}:${ENCODED_PASSWORD}@${CAMERA_IP}:${CAMERA_RTSP_PORT}/" + docker run --rm --network host linuxserver/ffmpeg:latest \ + ffprobe -v error "${SIMPLE_URL}" 2>&1 | head -5 +fi + +echo "" +echo "Checking MediaMTX container logs..." +docker logs "${PROJECT_NAME}-mediamtx" --tail 20 2>&1 | grep -E "(ERR|WARN|connected|disconnected|error)" \ No newline at end of file