Media Tools

Media Tools

Software and utilities for media processing, streaming, and management


Available Tools

Termux DLNA Server

A Python-based media server that runs on Android devices via Termux. Serves movies and TV shows from SMB shares to Kodi over DLNA/UPnP with automatic hardware-accelerated transcoding.

Key Features:

Use Case: Run a media server on your phone to stream to Kodi without a dedicated server.


Overview

The Media Tools section contains software for:

These tools demonstrate how to build robust media systems that work across devices and platforms.



Tools for building the media infrastructure of the future.

Termux DLNA Server - Mobile Media Streaming

Termux DLNA Server

Run on your phone, serve Movies/TV Shows from SMB share to Kodi over DLNA with hardware-accelerated transcoding


Overview

The Termux DLNA Server is a Python-based media server that runs on Android devices via Termux. It serves movies and TV shows from an SMB (Samba) network share to Kodi media center over DLNA/UPnP, with automatic hardware-accelerated transcoding to h264/AAC 720p when needed.

This enables you to:

  • Run a media server directly on your phone
  • Access your SMB shared media library
  • Stream to Kodi on Raspberry Pi, TV, or other devices
  • Transcode incompatible formats on-the-fly using hardware acceleration
  • Extract and serve forced subtitles

Architecture

┌─────────────────────────────────────────────────────────┐
│                    Termux DLNA Server                       │
│  (Python on Android via Termux)                            │
├─────────────────────────────────────────────────────────┤
│                                                                 │
│  ┌────────────┐  ┌────────────┐  ┌────────────────────┐  │
│  │ main.py     │  │ config.py   │  │ server.py           │  │
│  │ (Entry)     │  │ (Settings)  │  │ (HTTP Server)       │  │
│  └──────┬──────┘  └────────────┘  └──────────┬─────────┘  │
│         │                                      │              │
│         ▼                                      ▼              ▼
│  ┌────────────────────┐  ┌────────────┐  ┌────────────┐
│  │ scanner.py          │  │ ssdp.py     │  │ cds.py      │
│  │ (Library Scanner)   │  │ (Discovery)  │  │ (DLNA CDFS) │
│  └────────┬────────────┘  └────────────┘  └────────────┘
│           │                                                   │
│           ▼                                                   ▼
│  ┌────────────────────┐           ┌────────────────────────────┐
│  │ transcode.py        │           │ db.py                       │
│  │ (Transcoding Logic)  │           │ (SQLite Library Database)   │
│  └────────┬────────────┘           └────────────────────────────┘
│           │                                                   
│           ▼                                                   
│  ┌────────────────────┐                                    
│  │ smb_layer.py        │                                    
│  │ (SMB Access Layer)   │                                    
│  └────────────────────┘                                    
│                                                                 │
└─────────────────────────────────────────────────────────┘
         │
         ▼
┌─────────────────────────────────────────────────────────┐
│              Kodi (Client)                                │
│  - Discovers server via SSDP                               │
│  - Browses library via DLNA CDFS                           │
│  - Streams with forced subtitles                           │
└─────────────────────────────────────────────────────────┘

Features

Core Capabilities

FeatureDescription
DLNA/UPnP ServerFull DLNA ContentDirectory service implementation
SMB ClientReconnect-on-failure wrapper for SMB access
Library ManagementSQLite database for Movies/TV Shows/Seasons/Episodes tree
Automatic ScanningWalks SMB share, populates DB, periodic rescan with mark-and-sweep
Format Detectionffprobe inspection to determine video/audio codec, resolution, container
Hardware TranscodingUses h264_mediacodec for hardware-accelerated h264 encoding
Forced SubtitlesExtracts forced subtitles to SRT, advertises via DLNA
Direct StreamingByte-range passthrough for compatible files (no transcoding)

Playback Decision Logic

The server makes intelligent decisions about when to transcode:

Read more...