Skip to content

Latest commit

 

History

History
405 lines (312 loc) · 10.4 KB

TROUBLESHOOTING.md

File metadata and controls

405 lines (312 loc) · 10.4 KB

LightNVR Troubleshooting Guide

This document provides solutions for common issues you might encounter when using LightNVR.

Table of Contents

  1. Installation Issues
  2. Startup Problems
  3. Stream Connection Issues
  4. Recording Problems
  5. Web Interface Issues
  6. Performance Optimization
  7. Memory Usage
  8. Log File Analysis

Installation Issues

Missing Dependencies

If you encounter errors about missing dependencies during installation:

Error: Required dependency not found: libavcodec

Install the required dependencies:

Debian/Ubuntu:

sudo apt-get update
sudo apt-get install -y \
    build-essential \
    cmake \
    pkg-config \
    libsqlite3-dev \
    libavcodec-dev \
    libavformat-dev \
    libavutil-dev \
    libswscale-dev \
    libmicrohttpd-dev \
    libcurl4-openssl-dev \
    libssl-dev

Fedora/RHEL/CentOS:

sudo dnf install -y \
    gcc \
    gcc-c++ \
    make \
    cmake \
    pkgconfig \
    sqlite-devel \
    ffmpeg-devel \
    libmicrohttpd-devel \
    libcurl-devel \
    openssl-devel

Build Errors

If you encounter build errors:

  1. Make sure all dependencies are installed
  2. Clean the build directory and try again:
    ./scripts/build.sh --clean
  3. Check the CMake output for specific error messages

Startup Problems

Service Won't Start

If the LightNVR service won't start:

  1. Check the systemd status:

    sudo systemctl status lightnvr
  2. Check the log file for error messages:

    sudo tail -f /var/log/lightnvr.log
  3. Verify that the configuration file exists and is valid:

    sudo cat /etc/lightnvr/lightnvr.conf
  4. Check permissions on directories:

    sudo ls -la /var/lib/lightnvr
    sudo ls -la /var/log/lightnvr

PID File Issues

If you see errors related to the PID file:

  1. Remove the stale PID file:

    sudo rm /var/run/lightnvr.pid
  2. Ensure the directory exists and has the correct permissions:

    sudo mkdir -p /var/run/lightnvr
    sudo chown -R root:root /var/run/lightnvr

Stream Connection Issues

Can't Connect to Camera

If LightNVR can't connect to a camera:

  1. Verify that the camera is online and accessible:

    ping camera-ip-address
  2. Test the RTSP URL with another tool like VLC or ffmpeg:

    ffplay rtsp://username:password@camera-ip:554/stream1
  3. Check for authentication issues in the log file:

    grep "authentication" /var/log/lightnvr.log
  4. Verify network connectivity between the LightNVR server and the camera

Stream Disconnects Frequently

If streams disconnect frequently:

  1. Check your network stability
  2. Reduce the stream resolution or frame rate in the configuration
  3. Verify that the camera isn't overloaded with too many connections
  4. Check if the camera has a limit on concurrent RTSP connections

Live Stream Video Timeouts

If you experience frequent video timeouts in the live stream:

  1. Adjust HLS.js buffer settings in web/js/components/video.js:

    const hls = new Hls({
        maxBufferLength: 60,            // Increase for more buffering (default: 30)
        maxMaxBufferLength: 120,        // Maximum buffer size in seconds (default: 60)
        liveSyncDurationCount: 5,       // Number of segments to sync (default: 3)
        fragLoadingTimeOut: 20000,      // Fragment loading timeout in ms (default: 8000)
        manifestLoadingTimeOut: 15000,  // Manifest loading timeout in ms (default: 10000)
        levelLoadingTimeOut: 15000      // Level loading timeout in ms (default: 10000)
    });
  2. Increase server-side timeouts in src/web/api_handlers_streaming.c:

    • For manifest files: Increase the number of attempts and/or the wait time between attempts
    • For segment files: Increase the number of attempts and/or the wait time between attempts
  3. Adjust HLS segment settings in src/video/hls_writer.c:

    • Increase hls_list_size for more segments in the playlist
    • Add additional HLS flags to improve streaming reliability
  4. Network and hardware considerations:

    • Ensure your network has sufficient bandwidth for the configured stream quality
    • If running on limited hardware (like Ingenic A1), reduce stream resolution and framerate
    • Consider enabling hardware acceleration if available

Stale Stream Data in Live View

If you notice the live stream showing outdated video (stale data):

  1. Prevent browser caching:

    • Add cache control headers to HLS responses in src/web/api_handlers_streaming.c:
      set_response_header(response, "Cache-Control", "no-cache, no-store, must-revalidate");
      set_response_header(response, "Pragma", "no-cache");
      set_response_header(response, "Expires", "0");
  2. Add cache-busting to HLS URLs in web/js/components/video.js:

    const timestamp = Date.now();
    const hlsStreamUrl = `/api/streaming/${encodeURIComponent(stream.name)}/hls/index.m3u8?_t=${timestamp}`;
  3. Implement periodic stream refresh:

    const refreshInterval = 60000; // 60 seconds
    const refreshTimer = setInterval(() => {
        if (videoCell && videoCell.hlsPlayer) {
            const newTimestamp = Date.now();
            const newUrl = `/api/streaming/${encodeURIComponent(stream.name)}/hls/index.m3u8?_t=${newTimestamp}`;
            videoCell.hlsPlayer.loadSource(newUrl);
        }
    }, refreshInterval);
  4. Manual refresh: If you still see stale data, refreshing the browser page will force a complete reload of the stream.

Recording Problems

Recordings Not Being Created

If recordings aren't being created:

  1. Check if the stream is properly connected

  2. Verify that recording is enabled for the stream:

    grep "record" /etc/lightnvr/lightnvr.conf
  3. Check permissions on the recordings directory:

    ls -la /var/lib/lightnvr/recordings
  4. Check available disk space:

    df -h

Corrupt Recordings

If recordings are corrupt:

  1. Check if the stream is stable or frequently disconnecting
  2. Verify that the system has enough resources (CPU, memory)
  3. Check if the storage device is reliable and not failing
  4. Try reducing the recording quality or segment duration

Web Interface Issues

Can't Access Web Interface

If you can't access the web interface:

  1. Verify that the LightNVR service is running:

    sudo systemctl status lightnvr
  2. Check if the web server is listening on the configured port:

    sudo netstat -tuln | grep 8080
  3. Check firewall settings:

    sudo iptables -L
  4. Verify that the web root directory exists and has the correct permissions:

    ls -la /var/lib/lightnvr/www

Authentication Issues

If you're having trouble with authentication:

  1. Reset the username and password in the configuration file:

    sudo nano /etc/lightnvr/lightnvr.conf

    Update these lines:

    web_auth_enabled=true
    web_username=admin
    web_password=admin
    
  2. Restart the service:

    sudo systemctl restart lightnvr

Performance Optimization

High CPU Usage

If LightNVR is using too much CPU:

  1. Reduce the number of streams
  2. Lower the resolution and frame rate of streams
  3. Use hardware acceleration if available:
    hw_accel_enabled=true
    hw_accel_device=
    
  4. Reduce the buffer size:
    buffer_size=512  # Buffer size in KB
    

High Memory Usage

If LightNVR is using too much memory:

  1. Reduce the number of streams
  2. Lower the resolution and frame rate of streams
  3. Reduce the buffer size
  4. Enable and configure swap:
    use_swap=true
    swap_file=/var/lib/lightnvr/swap
    swap_size=134217728  # 128MB in bytes
    

Memory Usage on Ingenic A1

The Ingenic A1 SoC has only 256MB of RAM, so memory optimization is crucial:

  1. Limit the number of streams (4-8 maximum)
  2. Use lower resolutions (720p or less)
  3. Use lower frame rates (5-10 FPS)
  4. Set appropriate buffer sizes (512KB or less)
  5. Enable swap for additional virtual memory
  6. Set stream priorities to ensure important streams get resources

Example configuration for Ingenic A1:

# Memory Optimization for Ingenic A1
buffer_size=512  # 512KB buffer size
use_swap=true
swap_file=/var/lib/lightnvr/swap
swap_size=134217728  # 128MB in bytes
max_streams=8

# Stream example with optimized settings
stream.0.name=Front Door
stream.0.url=rtsp://192.168.1.100:554/stream1
stream.0.enabled=true
stream.0.width=1280
stream.0.height=720
stream.0.fps=10
stream.0.codec=h264
stream.0.priority=10
stream.0.record=true
stream.0.segment_duration=900

Log File Analysis

The log file is your best resource for troubleshooting. Here's how to analyze it:

  1. View the entire log file:

    cat /var/log/lightnvr.log
  2. View only error messages:

    grep "ERROR" /var/log/lightnvr.log
  3. View only warning messages:

    grep "WARN" /var/log/lightnvr.log
  4. Follow the log file in real-time:

    tail -f /var/log/lightnvr.log
  5. Check for specific issues:

    grep "stream" /var/log/lightnvr.log
    grep "recording" /var/log/lightnvr.log
    grep "database" /var/log/lightnvr.log

Common Log Messages

Here are some common log messages and what they mean:

  • Failed to connect to stream: The RTSP connection to the camera failed
  • Stream disconnected: The stream connection was lost
  • Failed to create recording directory: Permission issue or disk full
  • Database error: Problem with the SQLite database
  • Out of memory: The system is running out of RAM
  • Swap file created: Swap file was successfully created
  • Web server started on port 8080: Web server is running correctly
  • Authentication failed: Someone tried to access the web interface with incorrect credentials

Getting Help

If you're still having issues after trying these troubleshooting steps:

  1. Check the GitHub repository for known issues
  2. Search the issue tracker for similar problems
  3. Create a new issue with:
    • A clear description of the problem
    • Steps to reproduce
    • Relevant log file excerpts
    • Your system information (OS, hardware, etc.)
    • Your configuration file (with passwords removed)