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 \
libuv1-dev \
libcurl4-openssl-dev \
libssl-devFedora/RHEL/CentOS:
sudo dnf install -y \
gcc \
gcc-c++ \
make \
cmake \
pkgconfig \
sqlite-devel \
ffmpeg-devel \
libuv-devel \
libcurl-devel \
openssl-develIf 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.ini
-
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 see bufferAppendError messages in the browser console, this typically indicates that HLS segments are not properly formatted or don't start with keyframes. This has been fixed in recent versions by:
- Forcing keyframes at segment boundaries - The HLS writer now forces keyframes (I-frames) at the start of each segment
- Increased playlist size - The
hls_list_sizehas been increased from 3 to 6 segments for better buffering - Improved error recovery - HLS.js retry attempts have been increased
If you still experience issues:
-
Check camera GOP (Group of Pictures) settings:
- Ensure your camera's keyframe interval is set to 2 seconds or less
- Some cameras call this "I-frame interval" or "GOP size"
- For a 15 FPS stream, GOP should be 30 frames or less
- For a 30 FPS stream, GOP should be 60 frames or less
-
Verify stream codec:
- Ensure the camera is sending H.264 video
- Check that the stream doesn't have B-frames (use baseline or main profile, not high profile)
-
Check server logs for HLS writer errors:
docker logs lightnvr | grep -i "hls"
If you experience frequent video timeouts in the live stream:
-
Adjust HLS.js buffer settings in
web/js/components/preact/HLSVideoCell.jsx: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
-
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.ini -
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
Note: For detailed web interface troubleshooting, including blank page issues, see TROUBLESHOOTING_WEB_INTERFACE.md
If you see a blank page with the title "WebRTC View - LightNVR" but no content:
For Docker:
# Check volume mounts and recreate container
docker compose down
docker compose up -dFor Native Installation:
# Install/reinstall web assets (requires source directory)
sudo bash scripts/install_web_assets.sh
# Restart service
sudo systemctl restart lightnvrCause: Web assets (HTML, CSS, JavaScript files) were not installed to /var/lib/lightnvr/www/ or were overwritten by incorrect Docker volume mounts
See TROUBLESHOOTING_WEB_INTERFACE.md for detailed instructions.
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.ini
Update these lines in the
[web]section:[web] auth_enabled = true username = admin ; Remove or comment out the password line to have it auto-generated on next restart ; password =
-
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)