diff --git a/squashkiwi-streaming/test-camera.sh b/squashkiwi-streaming/test-camera.sh index ab80393..49fe3b1 100755 --- a/squashkiwi-streaming/test-camera.sh +++ b/squashkiwi-streaming/test-camera.sh @@ -19,6 +19,34 @@ echo "Camera IP: ${CAMERA_IP}" echo "Camera User: ${CAMERA_USER}" echo "RTSP Port: ${CAMERA_RTSP_PORT}" +# Test basic network connectivity first +echo "" +echo "Testing network connectivity to camera..." +if ping -c 1 -W 2 "${CAMERA_IP}" > /dev/null 2>&1; then + echo "✓ Camera IP is reachable" +else + echo "✗ Cannot reach camera at ${CAMERA_IP}" + echo " Please check:" + echo " - Camera IP address is correct" + echo " - Camera is powered on" + echo " - Network routing/firewall allows connection" + exit 1 +fi + +# Test RTSP port +echo "" +echo "Testing RTSP port ${CAMERA_RTSP_PORT}..." +if timeout 2 bash -c "echo > /dev/tcp/${CAMERA_IP}/${CAMERA_RTSP_PORT}" 2>/dev/null; then + echo "✓ RTSP port is open" +else + echo "✗ RTSP port ${CAMERA_RTSP_PORT} is not accessible" + echo " Please check:" + echo " - RTSP is enabled on the camera" + echo " - Port number is correct" + echo " - No firewall blocking port ${CAMERA_RTSP_PORT}" + exit 1 +fi + # 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') @@ -29,11 +57,13 @@ echo "Testing RTSP URL (password hidden): rtsp://${CAMERA_USER}:****@${CAMERA_IP # Test with ffprobe echo "" -echo "Testing with ffprobe..." -docker run --rm --network host \ +echo "Testing with ffprobe (10 second timeout)..." +timeout 10 docker run --rm --network host \ --entrypoint ffprobe \ linuxserver/ffmpeg:latest \ -v error \ + -rtsp_transport tcp \ + -timeout 5000000 \ "${RTSP_URL}" 2>&1 | head -20 if [ $? -eq 0 ]; then