Files
usda-vision/diagnose_rtsp.sh
salirezav 3cb6a8e76e Refactor MediaMTX configuration and enhance RTSP streaming logging
- Removed outdated timeout settings from MediaMTX configuration for improved stream handling.
- Updated CameraStreamer class to include detailed logging for RTSP streaming state and frame dimension checks.
- Added environment variable support for configuring MediaMTX host, enhancing flexibility in deployment.
2025-11-01 12:58:30 -04:00

88 lines
3.1 KiB
Bash
Executable File

#!/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 ""