This document describes the configuration options for LightNVR.
LightNVR supports two configuration file formats:
- INI format (recommended): A structured configuration format with sections and key-value pairs.
- Legacy key-value format: A simple key-value configuration format.
By default, LightNVR looks for a configuration file in the following locations (in order):
./lightnvr.ini
(INI format in current directory)/etc/lightnvr/lightnvr.ini
(INI format in system directory)./lightnvr.conf
(legacy format in current directory)/etc/lightnvr/lightnvr.conf
(legacy format in system directory)
You can specify a different configuration file using the -c
option:
./lightnvr -c /path/to/config.conf
When saving configuration changes through the web interface, LightNVR will prefer to use the INI format.
The INI format is a structured configuration format that organizes settings into sections. Here's an example of the same configuration in INI format:
; LightNVR Configuration File (INI format)
[general]
pid_file = /var/run/lightnvr.pid
log_file = /var/log/lightnvr.log
log_level = 2 ; 0=ERROR, 1=WARN, 2=INFO, 3=DEBUG
[storage]
path = /var/lib/lightnvr/recordings
max_size = 0 ; 0 means unlimited, otherwise bytes
retention_days = 30
auto_delete_oldest = true
[database]
path = /var/lib/lightnvr/lightnvr.db
[models]
path = /var/lib/lightnvr/models
[web]
port = 8080
root = /var/lib/lightnvr/www
auth_enabled = true
username = admin
password = admin ; IMPORTANT: Change this default password!
[streams]
max_streams = 16
; Note: Stream configurations are stored in the database
; This section is for reference only
; Example stream configuration:
; [stream_0]
; name = Front Door
; url = rtsp://192.168.1.100:554/stream1
; enabled = true
; width = 1920
; height = 1080
; fps = 15
; codec = h264
; priority = 10
; record = true
; segment_duration = 900 ; 15 minutes in seconds
[memory]
buffer_size = 1024 ; Buffer size in KB
use_swap = true
swap_file = /var/lib/lightnvr/swap
swap_size = 134217728 ; 128MB in bytes
[hardware]
hw_accel_enabled = false
hw_accel_device =
The INI format offers several advantages:
- Simple and widely used format
- Easy to read and edit
- Organized into sections
- Support for comments
- Lightweight parsing
The configuration file is divided into several sections:
# General Settings
pid_file=/var/run/lightnvr.pid
log_file=/var/log/lightnvr.log
log_level=2 # 0=ERROR, 1=WARN, 2=INFO, 3=DEBUG
pid_file
: Path to the PID filelog_file
: Path to the log filelog_level
: Logging level (0=ERROR, 1=WARN, 2=INFO, 3=DEBUG)
# Storage Settings
storage_path=/var/lib/lightnvr/recordings
max_storage_size=0 # 0 means unlimited, otherwise bytes
retention_days=30
auto_delete_oldest=true
storage_path
: Directory where recordings are storedmax_storage_size
: Maximum storage size in bytes (0 means unlimited)retention_days
: Number of days to keep recordingsauto_delete_oldest
: Whether to automatically delete the oldest recordings when storage is full
# Models Settings
models_path=/var/lib/lightnvr/models
models_path
: Directory where detection models are stored
# Database Settings
db_path=/var/lib/lightnvr/lightnvr.db
db_path
: Path to the SQLite database file
# Web Server Settings
web_port=8080
web_root=/var/lib/lightnvr/www
web_auth_enabled=true
web_username=admin
web_password=admin # IMPORTANT: Change this default password!
web_port
: Port for the web interfaceweb_root
: Directory containing web interface filesweb_auth_enabled
: Whether to enable authentication for the web interfaceweb_username
: Username for web interface authenticationweb_password
: Password for web interface authentication
# Stream Settings
max_streams=16
max_streams
: Maximum number of streams to support
# Memory Optimization
buffer_size=1024 # Buffer size in KB
use_swap=true
swap_file=/var/lib/lightnvr/swap
swap_size=134217728 # 128MB in bytes
buffer_size
: Buffer size for video processing in KBuse_swap
: Whether to use a swap file for additional memoryswap_file
: Path to the swap fileswap_size
: Size of the swap file in bytes
# Hardware Acceleration
hw_accel_enabled=false
hw_accel_device=
hw_accel_enabled
: Whether to enable hardware accelerationhw_accel_device
: Device to use for hardware acceleration
Each stream is configured with a set of parameters:
# Stream 0
stream.0.name=Front Door
stream.0.url=rtsp://192.168.1.100:554/stream1
stream.0.enabled=true
stream.0.width=1920
stream.0.height=1080
stream.0.fps=15
stream.0.codec=h264
stream.0.priority=10
stream.0.record=true
stream.0.segment_duration=900 # 15 minutes in seconds
stream.N.name
: Name of the streamstream.N.url
: URL of the stream (RTSP or ONVIF)stream.N.enabled
: Whether the stream is enabledstream.N.width
: Width of the stream in pixelsstream.N.height
: Height of the stream in pixelsstream.N.fps
: Frame rate of the streamstream.N.codec
: Codec of the stream (h264 or h265)stream.N.priority
: Priority of the stream (1-10, higher = more important)stream.N.record
: Whether to record the streamstream.N.segment_duration
: Duration of each recording segment in seconds
Here's a complete example configuration file:
# LightNVR Configuration File
# General Settings
pid_file=/var/run/lightnvr.pid
log_file=/var/log/lightnvr.log
log_level=2 # 0=ERROR, 1=WARN, 2=INFO, 3=DEBUG
# Storage Settings
storage_path=/var/lib/lightnvr/recordings
max_storage_size=0 # 0 means unlimited, otherwise bytes
retention_days=30
auto_delete_oldest=true
# Database Settings
db_path=/var/lib/lightnvr/lightnvr.db
# Models Settings
models_path=/var/lib/lightnvr/models
# Web Server Settings
web_port=8080
web_root=/var/lib/lightnvr/www
web_auth_enabled=true
web_username=admin
web_password=admin # IMPORTANT: Change this default password!
# Stream Settings
max_streams=16
# Memory Optimization
buffer_size=1024 # Buffer size in KB
use_swap=true
swap_file=/var/lib/lightnvr/swap
swap_size=134217728 # 128MB in bytes
# Hardware Acceleration
hw_accel_enabled=false
hw_accel_device=
# Stream Configurations
stream.0.name=Front Door
stream.0.url=rtsp://192.168.1.100:554/stream1
stream.0.enabled=true
stream.0.width=1920
stream.0.height=1080
stream.0.fps=15
stream.0.codec=h264
stream.0.priority=10
stream.0.record=true
stream.0.segment_duration=900 # 15 minutes in seconds
stream.1.name=Back Yard
stream.1.url=rtsp://192.168.1.101:554/stream1
stream.1.enabled=true
stream.1.width=1280
stream.1.height=720
stream.1.fps=10
stream.1.codec=h264
stream.1.priority=5
stream.1.record=true
stream.1.segment_duration=900 # 15 minutes in seconds
LightNVR supports the following command line options:
-c, --config FILE
: Use the specified configuration file-d, --daemon
: Run as a daemon-h, --help
: Show help message-v, --version
: Show version information
The Ingenic A1 SoC has limited memory (256MB), so it's important to optimize memory usage:
-
Set appropriate buffer sizes:
buffer_size=512 # 512KB buffer size
-
Enable swap file for additional memory:
use_swap=true swap_file=/var/lib/lightnvr/swap swap_size=134217728 # 128MB in bytes
-
Limit the number of streams and their resolution/frame rate:
max_streams=8 stream.0.width=1280 stream.0.height=720 stream.0.fps=10
-
Set stream priorities to ensure important streams get resources:
stream.0.priority=10 # High priority stream.1.priority=5 # Medium priority stream.2.priority=1 # Low priority
If you encounter issues with your configuration:
-
Check the log file for error messages:
tail -f /var/log/lightnvr/lightnvr.log
-
Verify that all paths in the configuration file exist and have the correct permissions
-
Test stream URLs separately using a tool like VLC or ffmpeg:
ffplay rtsp://192.168.1.100:554/stream1
-
Monitor memory usage to ensure you're not exceeding the available memory:
top -p $(pgrep lightnvr)