Remove deprecated files and scripts to streamline the codebase
- Deleted unused API test files, RTSP diagnostic scripts, and development utility scripts to reduce clutter. - Removed outdated database schema and modularization proposal documents to maintain focus on current architecture. - Cleaned up configuration files and logging scripts that are no longer in use, enhancing project maintainability.
This commit is contained in:
38
scripts/README.md
Normal file
38
scripts/README.md
Normal file
@@ -0,0 +1,38 @@
|
||||
# Scripts Directory
|
||||
|
||||
This directory contains utility scripts, test files, and diagnostic tools for the USDA Vision system.
|
||||
|
||||
## Shell Scripts (.sh)
|
||||
|
||||
- **`check_rtsp_status.sh`** - Quick RTSP streaming status check
|
||||
- Starts RTSP stream for camera1
|
||||
- Checks MediaMTX for stream availability
|
||||
- Displays access URLs (WebRTC, RTSP)
|
||||
|
||||
- **`diagnose_rtsp.sh`** - Comprehensive RTSP diagnostic tool
|
||||
- Performs full RTSP streaming health check
|
||||
- Tests API health, camera status, FFmpeg process
|
||||
- Verifies MediaMTX stream availability
|
||||
- Provides detailed diagnostic output
|
||||
|
||||
## Test Files
|
||||
|
||||
- **`api-tests.http`** - REST Client test file for API endpoints
|
||||
- Camera Management API tests
|
||||
- Media API tests
|
||||
- MediaMTX endpoint tests
|
||||
- Can be used with REST Client extensions in VS Code/Cursor
|
||||
|
||||
- **`test_rtsp.py`** - Python script for testing RTSP streaming functionality
|
||||
|
||||
## Usage
|
||||
|
||||
All scripts assume you're running from the project root directory and that Docker Compose services are running.
|
||||
|
||||
### Example:
|
||||
```bash
|
||||
# From project root
|
||||
./scripts/check_rtsp_status.sh
|
||||
./scripts/diagnose_rtsp.sh
|
||||
```
|
||||
|
||||
117
scripts/api-tests.http
Normal file
117
scripts/api-tests.http
Normal file
@@ -0,0 +1,117 @@
|
||||
###############
|
||||
# Environment #
|
||||
###############
|
||||
@host = exp-dash
|
||||
@web_port = 8080
|
||||
@api_port = 8000
|
||||
@media_port = 8090
|
||||
@rtsp_port = 8554
|
||||
|
||||
# Base URLs
|
||||
@WEB = http://{{host}}:{{web_port}}
|
||||
@API = http://{{host}}:{{api_port}}
|
||||
@MEDIA = http://{{host}}:{{media_port}}
|
||||
|
||||
|
||||
###########################
|
||||
# Camera Management (API) #
|
||||
###########################
|
||||
### API health
|
||||
GET {{API}}/health
|
||||
|
||||
### System status
|
||||
GET {{API}}/system/status
|
||||
|
||||
### List cameras
|
||||
GET {{API}}/cameras
|
||||
|
||||
### Get single camera status
|
||||
GET {{API}}/cameras/camera1/status
|
||||
|
||||
### Start live preview streaming (MJPEG) for camera1 (served by camera-management-api)
|
||||
POST {{API}}/cameras/camera1/start-stream
|
||||
|
||||
### Stop live preview streaming for camera1
|
||||
POST {{API}}/cameras/camera1/stop-stream
|
||||
|
||||
### View live MJPEG stream in browser (open URL)
|
||||
# {{API}}/cameras/camera1/stream
|
||||
|
||||
### Start RTSP streaming for camera1 (publishes to MediaMTX)
|
||||
POST {{API}}/cameras/camera1/start-rtsp
|
||||
|
||||
### Stop RTSP streaming for camera1
|
||||
POST {{API}}/cameras/camera1/stop-rtsp
|
||||
|
||||
### RTSP stream URL (use with VLC/ffplay):
|
||||
# rtsp://{{host}}:{{rtsp_port}}/camera1
|
||||
|
||||
|
||||
### getting a list of all videos
|
||||
GET {{MEDIA}}/videos/?page=10&limit=1
|
||||
|
||||
########################
|
||||
# Media API (media-api) #
|
||||
########################
|
||||
### Media API health
|
||||
GET {{MEDIA}}/health
|
||||
|
||||
### List videos (page 1, 24 per page)
|
||||
GET {{MEDIA}}/videos/?page=1&limit=24
|
||||
|
||||
### List videos filtered by camera name (example: camera1)
|
||||
GET {{MEDIA}}/videos/?page=1&limit=24&camera_name=camera1
|
||||
|
||||
### Get a thumbnail for a specific file (replace FILE_ID from list)
|
||||
# Tip: FILE_ID is URL-encoded relative path, e.g. camera1%2Fmy_video.mp4
|
||||
|
||||
@FILE_ID = camera2_auto_vibratory_conveyor_20251028_094749.mp4
|
||||
GET {{MEDIA}}/videos/{{FILE_ID}}/thumbnail?width=320&height=180
|
||||
|
||||
### Stream a file (basic GET without Range header)
|
||||
GET {{MEDIA}}/videos/{{FILE_ID}}/stream
|
||||
|
||||
### Stream a file with Range header (resume/seek)
|
||||
GET {{MEDIA}}/videos/{{FILE_ID}}/stream
|
||||
Range: bytes=0-1048575
|
||||
|
||||
|
||||
#########################################
|
||||
# RTSP / WebRTC via MediaMTX (mediamtx) #
|
||||
#########################################
|
||||
# Notes:
|
||||
# - RTSP is not directly playable in browsers; use VLC/ffplay/NVR.
|
||||
# - Example RTSP URL (for a path you configure or publish):
|
||||
# rtsp://{{host}}:{{rtsp_port}}/vod
|
||||
# - For on-demand publishing from a file, configure mediamtx.yml with runOnDemand ffmpeg.
|
||||
# - Quick client test examples (Run in your terminal):
|
||||
# ffplay -rtsp_transport tcp rtsp://{{host}}:{{rtsp_port}}/vod
|
||||
# vlc rtsp://{{host}}:{{rtsp_port}}/vod
|
||||
|
||||
# MediaMTX HTTP API (for checking streams)
|
||||
@MEDIAMTX_API = http://{{host}}:8889
|
||||
### Check MediaMTX version/info
|
||||
GET {{MEDIAMTX_API}}/v2/config/get
|
||||
|
||||
### List all available RTSP paths/streams
|
||||
GET {{MEDIAMTX_API}}/v2/paths/list
|
||||
|
||||
### Get info about a specific path (e.g., camera1)
|
||||
GET {{MEDIAMTX_API}}/v2/paths/get/camera1
|
||||
|
||||
# MediaMTX Web Interface (open in browser)
|
||||
# http://{{host}}:8889/static/
|
||||
|
||||
# If you enable WebRTC in MediaMTX, you can open its embedded player page (for testing):
|
||||
# See MediaMTX docs; by default we exposed RTSP and WebRTC ports in compose.
|
||||
|
||||
|
||||
###############################################
|
||||
# Useful manual test values (copy/paste below) #
|
||||
###############################################
|
||||
# @name set-variables
|
||||
# file_id examples (replace with values from /videos/):
|
||||
# camera1%2Fcamera1_auto_blower_separator_20251030_160405.mp4
|
||||
# camera2%2Ffoo_20251030_101010.mp4
|
||||
|
||||
|
||||
72
scripts/check_rtsp_status.sh
Executable file
72
scripts/check_rtsp_status.sh
Executable file
@@ -0,0 +1,72 @@
|
||||
#!/bin/bash
|
||||
# Quick script to check RTSP streaming status
|
||||
|
||||
echo "=== RTSP Streaming Status Check ==="
|
||||
echo ""
|
||||
|
||||
echo "1. Starting RTSP stream (if not already running)..."
|
||||
RESPONSE=$(curl -s -X POST http://exp-dash:8000/cameras/camera1/start-rtsp)
|
||||
echo "$RESPONSE" | python3 -m json.tool 2>/dev/null || echo "$RESPONSE"
|
||||
echo ""
|
||||
|
||||
echo "2. Waiting for stream to initialize (5 seconds)..."
|
||||
sleep 5
|
||||
|
||||
echo "3. Checking MediaMTX for stream..."
|
||||
PATH_INFO=$(curl -s http://localhost:8889/v2/paths/get/camera1 2>/dev/null)
|
||||
if [ -n "$PATH_INFO" ] && [ "$PATH_INFO" != "null" ] && [ "$PATH_INFO" != "{}" ]; then
|
||||
echo "$PATH_INFO" | python3 -m json.tool 2>/dev/null || echo "$PATH_INFO"
|
||||
SOURCE_READY=$(echo "$PATH_INFO" | python3 -c "import sys, json; d=json.load(sys.stdin); print(d.get('sourceReady', False))" 2>/dev/null || echo "false")
|
||||
if [ "$SOURCE_READY" = "True" ]; then
|
||||
echo ""
|
||||
echo "✅ Stream is READY!"
|
||||
else
|
||||
echo ""
|
||||
echo "⚠️ Stream path exists but source not ready yet"
|
||||
fi
|
||||
else
|
||||
echo "❌ Stream not found in MediaMTX"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
echo "4. Checking for FFmpeg process..."
|
||||
FFMPEG_PID=$(docker compose exec api bash -c "ps aux | grep '[f]fmpeg' | awk '{print \$2}'" 2>/dev/null | head -1)
|
||||
if [ -n "$FFMPEG_PID" ]; then
|
||||
echo "✅ FFmpeg is running (PID: $FFMPEG_PID)"
|
||||
else
|
||||
echo "❌ No FFmpeg process found"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
echo "5. Latest RTSP/FFmpeg logs..."
|
||||
docker compose logs api --tail 50 | grep -E "RTSP|FFmpeg|error|Broken pipe" | tail -10
|
||||
echo ""
|
||||
|
||||
echo "6. MediaMTX recent logs..."
|
||||
docker compose logs mediamtx --tail 10 | grep -E "camera1|RTSP|publishing"
|
||||
echo ""
|
||||
|
||||
# Get Tailscale IP
|
||||
TAILSCALE_IP=$(tailscale ip -4 2>/dev/null || echo "")
|
||||
if [ -z "$TAILSCALE_IP" ]; then
|
||||
TAILSCALE_IP=$(hostname -I | awk '{print $1}')
|
||||
fi
|
||||
|
||||
echo "=== Access URLs ==="
|
||||
echo ""
|
||||
echo "Your Tailscale IP: $TAILSCALE_IP"
|
||||
echo ""
|
||||
echo "📺 MediaMTX Web Interface (BEST - shows all streams with player):"
|
||||
echo " http://$TAILSCALE_IP:8889/static/"
|
||||
echo ""
|
||||
echo "📹 Direct WebRTC player for camera1:"
|
||||
echo " http://$TAILSCALE_IP:8889/camera1/webrtc"
|
||||
echo ""
|
||||
echo "🔗 RTSP URL (for VLC):"
|
||||
echo " rtsp://$TAILSCALE_IP:8554/camera1"
|
||||
echo ""
|
||||
echo "⚠️ IMPORTANT: Stream times out after ~10 seconds without a viewer!"
|
||||
echo " Start the stream, then QUICKLY open the web interface above"
|
||||
echo ""
|
||||
|
||||
|
||||
87
scripts/diagnose_rtsp.sh
Executable file
87
scripts/diagnose_rtsp.sh
Executable file
@@ -0,0 +1,87 @@
|
||||
#!/bin/bash
|
||||
# Comprehensive RTSP diagnostic script
|
||||
|
||||
echo "=========================================="
|
||||
echo "RTSP Streaming Diagnostic"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
echo "1. Checking API health..."
|
||||
API_HEALTH=$(curl -s http://exp-dash:8000/health 2>&1)
|
||||
if [ $? -eq 0 ]; then
|
||||
echo " ✅ API is responding"
|
||||
else
|
||||
echo " ❌ API is not responding"
|
||||
echo " Response: $API_HEALTH"
|
||||
exit 1
|
||||
fi
|
||||
echo ""
|
||||
|
||||
echo "2. Checking camera status..."
|
||||
CAMERA_STATUS=$(curl -s http://exp-dash:8000/cameras/camera1/status 2>&1)
|
||||
echo "$CAMERA_STATUS" | python3 -m json.tool 2>/dev/null || echo "$CAMERA_STATUS"
|
||||
echo ""
|
||||
|
||||
echo "3. Starting camera streaming..."
|
||||
curl -X POST http://exp-dash:8000/cameras/camera1/start-stream 2>&1 | python3 -m json.tool 2>/dev/null || curl -X POST http://exp-dash:8000/cameras/camera1/start-stream 2>&1
|
||||
echo ""
|
||||
|
||||
echo "4. Waiting for stream to initialize (8 seconds)..."
|
||||
sleep 8
|
||||
|
||||
echo "5. Starting RTSP streaming..."
|
||||
RTSP_RESPONSE=$(curl -s -X POST http://exp-dash:8000/cameras/camera1/start-rtsp)
|
||||
echo "$RTSP_RESPONSE" | python3 -m json.tool 2>/dev/null || echo "$RTSP_RESPONSE"
|
||||
echo ""
|
||||
|
||||
echo "6. Waiting for RTSP to initialize (10 seconds)..."
|
||||
sleep 10
|
||||
|
||||
echo "7. Checking for FFmpeg process..."
|
||||
FFMPEG_PID=$(docker compose exec api bash -c "ps aux | grep '[f]fmpeg' | grep -v grep | awk '{print \$2}'" 2>/dev/null | head -1)
|
||||
if [ -n "$FFMPEG_PID" ]; then
|
||||
echo " ✅ FFmpeg is running (PID: $FFMPEG_PID)"
|
||||
echo " Process details:"
|
||||
docker compose exec api bash -c "ps aux | grep '[f]fmpeg' | grep -v grep" 2>/dev/null
|
||||
else
|
||||
echo " ❌ FFmpeg is NOT running"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
echo "8. Checking API logs for RTSP activity..."
|
||||
echo " Recent RTSP/FFmpeg logs:"
|
||||
docker compose logs api --tail 100 | grep -E "RTSP|FFmpeg|frame dimensions|Waiting|Could not|Starting RTSP|Publishing|error|Error" | tail -20
|
||||
echo ""
|
||||
|
||||
echo "9. Checking MediaMTX for stream..."
|
||||
PATH_INFO=$(curl -s http://localhost:8889/v2/paths/get/camera1 2>/dev/null)
|
||||
if [ -n "$PATH_INFO" ] && [ "$PATH_INFO" != "null" ] && [ "$PATH_INFO" != "{}" ]; then
|
||||
echo " ✅ Stream path exists in MediaMTX"
|
||||
echo "$PATH_INFO" | python3 -m json.tool 2>/dev/null | head -20 || echo "$PATH_INFO"
|
||||
SOURCE_READY=$(echo "$PATH_INFO" | python3 -c "import sys, json; d=json.load(sys.stdin); print(d.get('sourceReady', False))" 2>/dev/null || echo "false")
|
||||
if [ "$SOURCE_READY" = "True" ]; then
|
||||
echo ""
|
||||
echo " ✅ Stream is READY!"
|
||||
else
|
||||
echo ""
|
||||
echo " ⚠️ Stream exists but source is not ready"
|
||||
fi
|
||||
else
|
||||
echo " ❌ Stream not found in MediaMTX"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
echo "10. MediaMTX recent activity..."
|
||||
docker compose logs mediamtx --tail 20 | grep -E "camera1|RTSP|publishing|session" | tail -10
|
||||
echo ""
|
||||
|
||||
echo "=========================================="
|
||||
echo "Diagnostic Complete"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
TAILSCALE_IP=$(tailscale ip -4 2>/dev/null || hostname -I | awk '{print $1}')
|
||||
echo "If stream is ready, try accessing:"
|
||||
echo " http://$TAILSCALE_IP:8889/static/"
|
||||
echo " http://$TAILSCALE_IP:8889/camera1/webrtc"
|
||||
echo ""
|
||||
|
||||
53
scripts/docker-compose-reset.sh
Normal file
53
scripts/docker-compose-reset.sh
Normal file
@@ -0,0 +1,53 @@
|
||||
#!/bin/bash
|
||||
# Docker Compose Reset Script
|
||||
# This script performs a complete reset of the Docker Compose environment:
|
||||
# - Stops and removes containers, networks, and volumes
|
||||
# - Prunes unused Docker resources (containers, images, networks, volumes)
|
||||
# - Rebuilds and starts all services in detached mode
|
||||
|
||||
set -e # Exit on error
|
||||
|
||||
echo "=== Docker Compose Reset ==="
|
||||
echo ""
|
||||
|
||||
# Get the project root directory (parent of scripts directory)
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
# Change to project root directory
|
||||
cd "$PROJECT_ROOT"
|
||||
|
||||
echo "Working directory: $PROJECT_ROOT"
|
||||
echo ""
|
||||
|
||||
echo "1. Stopping and removing containers, networks, and volumes..."
|
||||
docker compose down -v
|
||||
echo ""
|
||||
|
||||
echo "2. Pruning unused Docker resources..."
|
||||
echo " - Pruning unused containers..."
|
||||
docker container prune -f
|
||||
|
||||
echo " - Pruning unused images..."
|
||||
docker image prune -af
|
||||
|
||||
echo " - Pruning unused networks..."
|
||||
docker network prune -f
|
||||
|
||||
echo " - Pruning unused volumes..."
|
||||
docker volume prune -f
|
||||
echo ""
|
||||
|
||||
echo "3. Rebuilding and starting all services in detached mode..."
|
||||
docker compose up --build -d
|
||||
echo ""
|
||||
|
||||
echo "4. Checking service status..."
|
||||
docker compose ps
|
||||
echo ""
|
||||
|
||||
echo "=== Docker Compose Reset Complete ==="
|
||||
echo ""
|
||||
echo "All services have been reset and are running in detached mode."
|
||||
echo "Use 'docker compose logs -f' to view logs or 'docker compose ps' to check status."
|
||||
|
||||
113
scripts/test_rtsp.py
Normal file
113
scripts/test_rtsp.py
Normal file
@@ -0,0 +1,113 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Quick test script to verify RTSP streaming is working.
|
||||
Tests API endpoints and MediaMTX status.
|
||||
"""
|
||||
import requests
|
||||
import json
|
||||
import time
|
||||
import sys
|
||||
|
||||
API_BASE = "http://exp-dash:8000"
|
||||
MEDIAMTX_BASE = "http://exp-dash:8889"
|
||||
CAMERA = "camera1"
|
||||
|
||||
def test_api_rtsp():
|
||||
"""Test RTSP start endpoint"""
|
||||
print(f"\n{'='*60}")
|
||||
print(f"Testing RTSP streaming for {CAMERA}")
|
||||
print(f"{'='*60}\n")
|
||||
|
||||
# 1. Check if camera exists
|
||||
print(f"1. Checking camera status...")
|
||||
try:
|
||||
resp = requests.get(f"{API_BASE}/cameras/{CAMERA}/status", timeout=5)
|
||||
if resp.status_code == 200:
|
||||
print(f" ✅ Camera {CAMERA} found")
|
||||
print(f" Status: {json.dumps(resp.json(), indent=2)}")
|
||||
else:
|
||||
print(f" ❌ Camera {CAMERA} not found (status: {resp.status_code})")
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f" ❌ Error checking camera: {e}")
|
||||
return False
|
||||
|
||||
# 2. Start RTSP streaming
|
||||
print(f"\n2. Starting RTSP streaming...")
|
||||
try:
|
||||
resp = requests.post(f"{API_BASE}/cameras/{CAMERA}/start-rtsp", timeout=10)
|
||||
print(f" Response status: {resp.status_code}")
|
||||
print(f" Response: {json.dumps(resp.json(), indent=2)}")
|
||||
|
||||
if resp.status_code == 200 and resp.json().get("success"):
|
||||
print(f" ✅ RTSP streaming started successfully")
|
||||
rtsp_url = resp.json().get("rtsp_url", "N/A")
|
||||
print(f" RTSP URL: {rtsp_url}")
|
||||
else:
|
||||
print(f" ❌ Failed to start RTSP streaming")
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f" ❌ Error starting RTSP: {e}")
|
||||
return False
|
||||
|
||||
# 3. Wait a moment for FFmpeg to start
|
||||
print(f"\n3. Waiting for stream to initialize (5 seconds)...")
|
||||
time.sleep(5)
|
||||
|
||||
# 4. Check MediaMTX for the stream
|
||||
print(f"\n4. Checking MediaMTX for stream...")
|
||||
try:
|
||||
resp = requests.get(f"{MEDIAMTX_BASE}/v2/paths/list", timeout=5)
|
||||
if resp.status_code == 200:
|
||||
paths = resp.json()
|
||||
print(f" MediaMTX paths: {json.dumps(paths, indent=2)}")
|
||||
|
||||
# Check if our camera path exists
|
||||
if isinstance(paths, dict) and "items" in paths:
|
||||
items = paths.get("items", {})
|
||||
if CAMERA in items:
|
||||
path_info = items[CAMERA]
|
||||
source_ready = path_info.get("sourceReady", False)
|
||||
readers = path_info.get("readers", [])
|
||||
print(f" ✅ Path '{CAMERA}' found in MediaMTX")
|
||||
print(f" Source ready: {source_ready}")
|
||||
print(f" Active readers: {len(readers)}")
|
||||
if source_ready:
|
||||
print(f" ✅ Stream is ready!")
|
||||
else:
|
||||
print(f" ⚠️ Stream not ready yet (sourceReady=false)")
|
||||
else:
|
||||
print(f" ❌ Path '{CAMERA}' not found in MediaMTX")
|
||||
print(f" Available paths: {list(items.keys())}")
|
||||
else:
|
||||
print(f" ⚠️ Unexpected response format from MediaMTX")
|
||||
else:
|
||||
print(f" ⚠️ MediaMTX API returned status {resp.status_code}")
|
||||
except Exception as e:
|
||||
print(f" ⚠️ Error checking MediaMTX: {e}")
|
||||
|
||||
# 5. Check specific path
|
||||
print(f"\n5. Getting detailed info for path '{CAMERA}'...")
|
||||
try:
|
||||
resp = requests.get(f"{MEDIAMTX_BASE}/v2/paths/get/{CAMERA}", timeout=5)
|
||||
if resp.status_code == 200:
|
||||
info = resp.json()
|
||||
print(f" Path info: {json.dumps(info, indent=2)}")
|
||||
else:
|
||||
print(f" Path not found (status: {resp.status_code})")
|
||||
except Exception as e:
|
||||
print(f" Error: {e}")
|
||||
|
||||
print(f"\n{'='*60}")
|
||||
print(f"Test complete!")
|
||||
print(f"Try viewing the stream with:")
|
||||
print(f" vlc rtsp://exp-dash:8554/{CAMERA}")
|
||||
print(f" ffplay -rtsp_transport tcp rtsp://exp-dash:8554/{CAMERA}")
|
||||
print(f"{'='*60}\n")
|
||||
|
||||
return True
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_api_rtsp()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user