Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SlimDLNA - High-Performance DLNA Media Server

by NikitaY.com

A lightweight, high-performance DLNA/UPnP media server written in C++ with FFmpeg integration for macOS. Stream your video collection to any DLNA-compatible device on your local network.

Features

  • 🚀 High Performance: Written in C++ with optimized FFmpeg integration
  • 📹 Rich Metadata: Automatic extraction of video duration, resolution, codec, and bitrate
  • 🎬 Smart Scanning: Scans directories recursively and serves the 100 most recently modified videos
  • 📡 DLNA/UPnP: Full SSDP discovery and ContentDirectory service implementation
  • HTTP Range Support: Efficient video streaming with seek support
  • 🔄 Smart Transcoding: Optional on-the-fly H.264 transcoding for old TV compatibility (7+ years)
  • 🎯 Simple CLI: Easy-to-use command-line interface with flexible options

Supported Video Formats

  • MP4 (.mp4, .m4v)
  • MKV (.mkv)
  • AVI (.avi)
  • MOV (.mov)
  • WMV (.wmv)
  • FLV (.flv)
  • WebM (.webm)
  • MPEG (.mpg, .mpeg)

Requirements

  • macOS (tested on macOS 10.15+)
  • CMake 3.15 or later
  • Homebrew (for dependencies)

Installation

1. Install Dependencies

# Install Homebrew if not already installed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install required libraries
brew install cmake ffmpeg libmicrohttpd

2. Build from Source

# Clone or navigate to the project directory
cd SlimDLNA

# Create build directory
mkdir build && cd build

# Configure with CMake
cmake ..

# Build the project
make

# (Optional) Install system-wide
sudo make install

The compiled binary will be located at build/slimdlna.

Usage

Basic Usage

Run the server with default settings (scans ~/Movies/, transcoding enabled):

./slimdlna

Transcoding Options

Default (Transcoding ON) - Maximum compatibility with old TVs (7+ years):

./slimdlna                    # H.264/AAC transcode for old TVs
./slimdlna -t ~/Videos        # Explicit transcode enable

Direct Streaming (Transcoding OFF) - Faster, for modern devices:

./slimdlna -nt                # No transcoding (direct streaming)
./slimdlna --notranscode ~/Videos

Custom Server Name

./slimdlna --name "My Videos"
./slimdlna -n "MediaCenter" ~/Videos

Verbose Logging

./slimdlna -v                 # Basic verbose
./slimdlna -vv                # Detailed logging
./slimdlna -vvv               # Full debug output

Combined Options

./slimdlna -vv -n "HomeMovies" -nt ~/Videos

Help

Display usage information:

./slimdlna --help

How It Works

  1. Scanning: The server recursively scans the specified directory for video files
  2. Metadata Extraction: FFmpeg extracts detailed metadata (duration, resolution, codec, bitrate) from each video
  3. Selection: Up to 100 most recently modified videos are selected for serving
  4. SSDP Discovery: The server announces itself on the network via SSDP multicast (239.255.255.250:1900)
  5. DLNA Serving: Devices can browse the video library and stream content via HTTP on port 8200

Network Configuration

  • SSDP Port: 1900 (UDP, multicast)
  • HTTP Port: 8200 (TCP)
  • Protocol: DLNA/UPnP 1.0

Make sure these ports are not blocked by your firewall.

Connecting DLNA Devices

Once the server is running:

  1. Smart TVs: Look for "SlimDLNA Media Server" in your TV's media server list
  2. Game Consoles: Check the media player app for available servers
  3. Mobile Apps: Use any DLNA client app (e.g., BubbleUPnP, VLC)
  4. Computers: Use VLC, Kodi, or any UPnP/DLNA client

Troubleshooting

No Videos Found

  • Verify the directory path exists and contains video files
  • Check that video files have supported extensions
  • Ensure you have read permissions for the directory

Devices Can't Discover Server

  • Ensure both server and devices are on the same network
  • Check firewall settings (allow ports 1900 and 8200)
  • Some networks block multicast traffic - check router settings

Port Already in Use

If port 8200 or 1900 is already in use by another application, you'll need to stop that application first.

FFmpeg Errors

If you see FFmpeg-related errors during scanning:

# Verify FFmpeg installation
ffmpeg -version

# Reinstall if needed
brew reinstall ffmpeg

Performance Notes

Direct Streaming Mode (-nt)

  • Scanning Time: 1-5 seconds for 100 files
  • Memory Usage: ~20-50 MB
  • CPU Usage: Minimal (< 5%)
  • Network: Original bitrate (2-20 Mbps)

Transcoding Mode (Default)

  • Scanning Time: Same (1-5 seconds)
  • Memory Usage: ~100-200 MB per active stream
  • CPU Usage: 50-100% per stream (real-time encoding)
  • Network: 3-8 Mbps (optimized for old TVs)
  • Quality: H.264 Main Profile, AAC audio, 1080p max

Recommendation: Use -nt for modern devices (faster, original quality). Use default transcoding for TVs older than ~2018.

Architecture

Core Components

  • Scanner (scanner.cpp): Recursive directory scanning with FFmpeg metadata extraction
  • Media Library (media.cpp): Video file management and DIDL-Lite XML generation
  • HTTP Server (http_server.cpp): libmicrohttpd-based streaming with range request support
  • SSDP Responder (ssdp.cpp): UPnP device discovery via multicast
  • ContentDirectory (content_directory.cpp): UPnP ContentDirectory:1 service with SOAP interface

License

This project is provided as-is for educational and personal use.

Contributing

Contributions are welcome! Areas for improvement:

  • Additional codec support
  • Subtitle streaming
  • Thumbnail generation
  • Web-based management interface
  • Cross-platform support (Linux, Windows)

Credits

Created by NikitaY.com

Built with ❤️ using C++17, FFmpeg, and libmicrohttpd.


Note: This server is designed for local network use only. Do not expose it to the public internet without proper security measures.

© 2025 NikitaY.com. All rights reserved.

About

SlimDLNA - High-Performance DLNA Media Server (C++)

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Contributors

Languages