A lightweight HLS video streaming server built with Rust, featuring automatic video ID generation and web-based streaming.
- HLS Video Streaming: Serves
.m3u8playlists and.tsvideo segments - Clean URLs: Watch videos at
/watch?v=VIDEO_ID - Random Video IDs: Automatically generates 11-character video IDs
- FFmpeg Integration: Convert any video format to HLS using the built-in converter
- High Performance: Built with Rocket web framework for fast HTTP serving
simple-video-server-rs/
├── Cargo.toml # Workspace configuration
├── server/ # HTTP video server
│ ├── Cargo.toml
│ └── src/main.rs
├── cm3u8/ # Video-to-HLS converter
│ ├── Cargo.toml
│ └── src/main.rs
└── videos/ # Video storage
└── <VIDEO_ID>/ # Video ID folders
├── <VIDEO_ID>.m3u8 # HLS playlist
├── <VIDEO_ID>0.ts # Video segments
├── <VIDEO_ID>1.ts
└── ...
- Clone the repository:
git clone https://github.com/ywjno/simple-video-server-rs
cd simple-video-server-rs- Build the project:
cargo build --releaseUse the cm3u8 tool to convert your video files:
# Convert a video - automatically generates video ID
cargo run --release -p cm3u8 -- -i input_video.mp4
# Example output:
# Video ID: Xe5NCiPrw5s
# Playlist: ./Xe5NCiPrw5s/Xe5NCiPrw5s.m3u8This automatically:
- Generates a random 11-character video ID
- Creates a directory with the video ID
- Converts the video to HLS format with 10-second segments
# Move the generated video folder to the videos directory
mkdir -p videos
mv Xe5NCiPrw5s videos/# Start with default port (8080)
cargo run --release -p simple-video-server
# Or set a custom port
PORT=3000 cargo run --release -p simple-video-serverThe server will start at http://localhost:8080.
Open your browser or media player and navigate to:
http://localhost:8080/watch?v=Xe5NCiPrw5s
VLC Media Player:
- Open VLC
- Go to "Media" → "Open Network Stream"
- Enter:
http://localhost:8080/api/watch?v=Xe5NCiPrw5s - Click "Play"
Serves the HLS playlist for the specified video.
Parameters:
v: Video ID (11-character string)
Example:
GET /watch?v=Xe5NCiPrw5s
→ videos/Xe5NCiPrw5s/Xe5NCiPrw5s.m3u8
Serves video segments (.ts files) referenced by the playlist.
Parameters:
video_segment: Video segment filename (must end with.ts)
Example:
GET /Xe5NCiPrw5s0.ts
→ videos/Xe5NCiPrw5s/Xe5NCiPrw5s0.ts
Security: Only .ts files are served through this endpoint.
PORT: Server port (default: 8080)
The server is configured with:
- Bind address:
0.0.0.0(all interfaces) - Default port:
8080 - Log level: Normal (debug) / Critical (release)
- Route prefix:
/
Video IDs are generated using:
- Length: 11 characters
- Character set:
A-Z,a-z,2-9(excluding confusing characters like0,O,I,l,1) - Example:
dQw4w9WgXcQ
This ensures unique, readable video identifiers.
The converter uses these FFmpeg settings:
- Segment duration: 10 seconds
- Video codec: H.264 (libx264)
- Audio codec: AAC
- Hardware acceleration: Auto-detected
- Playlist type: HLS with unlimited segments
# Build all components
cargo build
# Build server only
cargo build -p simple-video-server
# Build converter only
cargo build -p cm3u8
# Run in development mode
cargo run -p simple-video-serverServer:
rocket- Web framework
Converter:
clap- Command-line argument parsingrand- Random video ID generation
Videos are organized as follows:
videos/
├── Xe5NCiPrw5s/
│ ├── Xe5NCiPrw5s.m3u8 # Playlist
│ ├── Xe5NCiPrw5s0.ts # Segment 0
│ ├── Xe5NCiPrw5s1.ts # Segment 1
│ └── ...
└── ...
This project is dual-licensed under either of:
- MIT License
- Apache License 2.0
You may choose either license for your use.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request