This document provides solutions for common issues you might encounter when using LightNVR.
- Installation Issues
- Startup Problems
- Stream Connection Issues
- Recording Problems
- Web Interface Issues
- Performance Optimization
- Memory Usage
- Log File Analysis
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
If you encounter build errors:
- Make sure all dependencies are installed
- Clean the build directory and try again:
./scripts/build.sh --clean
- Check the CMake output for specific error messages
If the LightNVR service won't start:
-
Check the systemd status:
sudo systemctl status lightnvr
-
Check the log file for error messages:
sudo tail -f /var/log/lightnvr.log
-
Verify that the configuration file exists and is valid:
sudo cat /etc/lightnvr/lightnvr.conf
-
Check permissions on directories:
sudo ls -la /var/lib/lightnvr sudo ls -la /var/log/lightnvr
If you see errors related to the PID file:
-
Remove the stale PID file:
sudo rm /var/run/lightnvr.pid
-
Ensure the directory exists and has the correct permissions:
sudo mkdir -p /var/run/lightnvr sudo chown -R root:root /var/run/lightnvr
If LightNVR can't connect to a camera:
-
Verify that the camera is online and accessible:
ping camera-ip-address
-
Test the RTSP URL with another tool like VLC or ffmpeg:
ffplay rtsp://username:password@camera-ip:554/stream1
-
Check for authentication issues in the log file:
grep "authentication" /var/log/lightnvr.log
-
Verify network connectivity between the LightNVR server and the camera
If streams disconnect frequently:
- Check your network stability
- Reduce the stream resolution or frame rate in the configuration
- Verify that the camera isn't overloaded with too many connections
- Check if the camera has a limit on concurrent RTSP connections
If you experience frequent video timeouts in the live stream:
-
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) });
-
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
-
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
- Increase
-
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
If you notice the live stream showing outdated video (stale data):
-
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");
- Add cache control headers to HLS responses in
-
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}`;
-
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);
-
Manual refresh: If you still see stale data, refreshing the browser page will force a complete reload of the stream.
If recordings aren't being created:
-
Check if the stream is properly connected
-
Verify that recording is enabled for the stream:
grep "record" /etc/lightnvr/lightnvr.conf
-
Check permissions on the recordings directory:
ls -la /var/lib/lightnvr/recordings
-
Check available disk space:
df -h
If recordings are corrupt:
- Check if the stream is stable or frequently disconnecting
- Verify that the system has enough resources (CPU, memory)
- Check if the storage device is reliable and not failing
- Try reducing the recording quality or segment duration
If you can't access the web interface:
-
Verify that the LightNVR service is running:
sudo systemctl status lightnvr
-
Check if the web server is listening on the configured port:
sudo netstat -tuln | grep 8080
-
Check firewall settings:
sudo iptables -L
-
Verify that the web root directory exists and has the correct permissions:
ls -la /var/lib/lightnvr/www
If you're having trouble with authentication:
-
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
-
Restart the service:
sudo systemctl restart lightnvr
If LightNVR is using too much CPU:
- Reduce the number of streams
- Lower the resolution and frame rate of streams
- Use hardware acceleration if available:
hw_accel_enabled=true hw_accel_device=
- Reduce the buffer size:
buffer_size=512 # Buffer size in KB
If LightNVR is using too much memory:
- Reduce the number of streams
- Lower the resolution and frame rate of streams
- Reduce the buffer size
- Enable and configure swap:
use_swap=true swap_file=/var/lib/lightnvr/swap swap_size=134217728 # 128MB in bytes
The Ingenic A1 SoC has only 256MB of RAM, so memory optimization is crucial:
- Limit the number of streams (4-8 maximum)
- Use lower resolutions (720p or less)
- Use lower frame rates (5-10 FPS)
- Set appropriate buffer sizes (512KB or less)
- Enable swap for additional virtual memory
- 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
The log file is your best resource for troubleshooting. Here's how to analyze it:
-
View the entire log file:
cat /var/log/lightnvr.log
-
View only error messages:
grep "ERROR" /var/log/lightnvr.log
-
View only warning messages:
grep "WARN" /var/log/lightnvr.log
-
Follow the log file in real-time:
tail -f /var/log/lightnvr.log
-
Check for specific issues:
grep "stream" /var/log/lightnvr.log grep "recording" /var/log/lightnvr.log grep "database" /var/log/lightnvr.log
Here are some common log messages and what they mean:
Failed to connect to stream
: The RTSP connection to the camera failedStream disconnected
: The stream connection was lostFailed to create recording directory
: Permission issue or disk fullDatabase error
: Problem with the SQLite databaseOut of memory
: The system is running out of RAMSwap file created
: Swap file was successfully createdWeb server started on port 8080
: Web server is running correctlyAuthentication failed
: Someone tried to access the web interface with incorrect credentials
If you're still having issues after trying these troubleshooting steps:
- Check the GitHub repository for known issues
- Search the issue tracker for similar problems
- 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)