Skip to content

Deploying VLC Media Server

Introduction

VLC (VideoLAN Client) is not just a media player - it’s also a powerful streaming server capable of transcoding and broadcasting multimedia content over various protocols. As a streaming server, VLC can serve video and audio to multiple clients simultaneously, convert between formats on-the-fly, and handle virtually any media format.

Key highlights of VLC Streaming:

  • Universal Format Support: Handle virtually any audio and video format
  • Protocol Support: Stream via HTTP, RTSP, RTP, UDP, and more
  • Transcoding: Convert media formats in real-time while streaming
  • Playlist Management: Create and manage streaming playlists
  • Web Interface: Remote control via HTTP interface
  • Low Resource Usage: Efficient streaming with minimal overhead
  • Cross-Platform: Works consistently across operating systems
  • Scriptable: Automate streaming with command-line options

This guide walks through deploying VLC as a streaming server on Klutch.sh using Docker, configuring streaming outputs, and setting up media broadcasts.

Why Deploy VLC Streaming on Klutch.sh

Deploying VLC streaming server on Klutch.sh provides several advantages:

Simplified Deployment: Klutch.sh automatically detects your Dockerfile and builds VLC without complex orchestration. Push to GitHub, and your streaming server deploys automatically.

Persistent Storage: Attach persistent volumes for your media library. Your content survives container restarts.

HTTPS by Default: Klutch.sh provides automatic SSL certificates for secure streaming access.

GitHub Integration: Connect your configuration repository directly from GitHub. Updates trigger automatic redeployments.

Scalable Resources: Allocate CPU and memory based on transcoding needs and viewer count.

Prerequisites

Before deploying VLC streaming on Klutch.sh, ensure you have:

  • A Klutch.sh account
  • A GitHub account with a repository for your configuration
  • Basic familiarity with Docker and containerization concepts
  • Media files to stream or a source URL

Preparing Your Repository

Create a GitHub repository containing your Dockerfile for VLC streaming deployment.

Repository Structure

vlc-streaming/
├── Dockerfile
├── stream.sh
├── playlist.m3u
└── .dockerignore

Creating the Dockerfile

FROM ubuntu:22.04
# Install VLC
RUN apt-get update && apt-get install -y \
vlc \
vlc-plugin-base \
&& rm -rf /var/lib/apt/lists/*
# Create vlc user (VLC won't run as root)
RUN useradd -m vlcuser
# Create media directory
RUN mkdir -p /media /config
RUN chown -R vlcuser:vlcuser /media /config
# Copy streaming script
COPY stream.sh /usr/local/bin/stream.sh
RUN chmod +x /usr/local/bin/stream.sh
# Copy playlist if provided
COPY playlist.m3u /config/playlist.m3u
# Set environment variables
ENV VLC_HTTP_PORT=${VLC_HTTP_PORT:-8080}
ENV VLC_HTTP_PASSWORD=${VLC_HTTP_PASSWORD:-admin}
ENV STREAM_SOURCE=${STREAM_SOURCE:-/media}
# Switch to non-root user
USER vlcuser
# Expose HTTP port for streaming
EXPOSE 8080
# Volume for media files
VOLUME ["/media"]
# Start VLC streaming
CMD ["/usr/local/bin/stream.sh"]

Creating the Streaming Script

Create a stream.sh file:

#!/bin/bash
# VLC Streaming Server Script
# HTTP streaming with web interface
vlc-wrapper \
--intf http \
--http-host 0.0.0.0 \
--http-port ${VLC_HTTP_PORT:-8080} \
--http-password ${VLC_HTTP_PASSWORD:-admin} \
--no-video-title-show \
--sout "#transcode{vcodec=h264,vb=800,acodec=mp3,ab=128,channels=2}:http{mux=ts,dst=:8080/stream}" \
--sout-keep \
--loop \
${STREAM_SOURCE:-/media}

Creating a Playlist

Create a playlist.m3u file:

#EXTM3U
#EXTINF:-1,Video 1
/media/video1.mp4
#EXTINF:-1,Video 2
/media/video2.mp4
#EXTINF:-1,Live Stream
http://example.com/live/stream.m3u8

Environment Variables Reference

VariableRequiredDefaultDescription
VLC_HTTP_PORTNo8080HTTP streaming port
VLC_HTTP_PASSWORDYesadminWeb interface password
STREAM_SOURCENo/mediaMedia source (file, directory, or URL)

Deploying VLC Streaming on Klutch.sh

    Push Your Repository to GitHub

    Initialize your repository and push to GitHub with your Dockerfile and streaming configuration.

    Create a New Project on Klutch.sh

    Navigate to the Klutch.sh dashboard and create a new project. Give it a descriptive name like “vlc-streaming” or “media-server”.

    Create a New App

    Within your project, create a new app. Connect your GitHub account if you haven’t already, then select the repository containing your VLC Dockerfile.

    Configure HTTP Traffic

    In the deployment settings:

    • Select HTTP as the traffic type
    • Set the internal port to 8080

    Set Environment Variables

    Add the following environment variables:

    VariableValue
    VLC_HTTP_PORT8080
    VLC_HTTP_PASSWORDYour secure password

    Attach Persistent Volumes

    Add the following volume:

    Mount PathRecommended SizePurpose
    /media50+ GBMedia files for streaming

    Allocate Resources

    VLC transcoding benefits from adequate resources:

    • CPU: 2+ cores for real-time transcoding
    • Memory: 2GB+ RAM recommended

    Deploy Your Application

    Click Deploy to start the build process. Klutch.sh will build the container, attach volumes, and provision an HTTPS certificate.

    Access Your Stream

    Once deployment completes:

    • Web Interface: https://your-app-name.klutch.sh
    • Stream URL: https://your-app-name.klutch.sh/stream

Streaming Configurations

HTTP Live Streaming

Stream to web browsers with HLS:

Terminal window
vlc-wrapper input.mp4 \
--sout "#transcode{vcodec=h264,vb=1000,acodec=aac,ab=128}:std{access=livehttp{seglen=10,index=/media/stream.m3u8},mux=ts,dst=/media/stream-###.ts}"

Transcoding Options

Adjust quality based on bandwidth:

Terminal window
# Low bandwidth
--sout "#transcode{vcodec=h264,vb=400,scale=0.5,acodec=mp3,ab=64}"
# High quality
--sout "#transcode{vcodec=h264,vb=2000,acodec=aac,ab=192}"
# Audio only
--sout "#transcode{acodec=mp3,ab=128}:http{mux=mp3,dst=:8080/radio}"

Multi-destination Streaming

Stream to multiple outputs:

Terminal window
--sout "#duplicate{dst=std{access=http,mux=ts,dst=:8080/stream1},dst=std{access=file,mux=mp4,dst=/media/recording.mp4}}"

Using the Web Interface

VLC’s HTTP interface provides:

  1. Playlist Management: Add, remove, and reorder media
  2. Playback Control: Play, pause, stop, and seek
  3. Volume Control: Adjust audio levels
  4. Stream Information: View current stream status

Access the interface at https://your-app-name.klutch.sh and enter your configured password.

Troubleshooting

Stream Not Playing

  • Verify the source media file exists and is accessible
  • Check VLC logs for codec or format issues
  • Ensure the output port matches your configuration

High CPU Usage

  • Reduce transcoding bitrate
  • Use hardware-accelerated encoding if available
  • Consider pre-transcoding media files

Connection Refused

  • Verify the HTTP port is correctly exposed
  • Check that VLC started successfully
  • Review container logs for errors

Additional Resources

Conclusion

Deploying VLC as a streaming server on Klutch.sh gives you a versatile media broadcasting solution with support for virtually any format. The combination of VLC’s powerful transcoding capabilities and Klutch.sh’s deployment simplicity means you can quickly set up media streaming for various use cases.