A distributed media processing system for transmuxing, transcoding, and packaging media files from various sources into streaming-ready formats.
MuxFarm provides a scalable architecture for processing media content, supporting ingestion from multiple storage backends and conversion to modern streaming formats like MPEG-DASH and HLS. Built with Go and leveraging FFmpeg for media operations, it's designed to handle large-scale media workflows.
- Transmuxing: Container format conversion (MP4, WebM, FLV, MPEG)
- Transcoding: Video (H.264, VP9, AV1) and audio (AAC, MP3, Opus) codec support
- Adaptive Streaming: MPEG-DASH and HLS packaging with segmentation
- Quality Control: Bitrate and resolution management
MuxFarm leverages FFmpeg's powerful multimedia framework through a comprehensive Go wrapper:
-
ffprobe: Media analysis and metadata extraction
- Container format detection
- Stream information parsing
- Duration and bitrate analysis
- Codec identification
-
ffmpeg: Core media processing engine
- Stream mapping and filtering
- Real-time transcoding with hardware acceleration support
- Custom filter graphs for complex transformations
- Pipe-based I/O for memory-efficient processing
-
Supported FFmpeg Features:
- Multiple input/output streams
- Format-specific optimization flags
- Metadata preservation and manipulation
- Time-based seeking and trimming
- Custom encoding parameters
- Local filesystem (LFS)
- HTTP/HTTPS URLs
- AWS S3 buckets
- Google Cloud Storage
- Git repositories
- gRPC-based service communication
- MongoDB for job persistence and state tracking
- Redis for distributed coordination and locking
- Horizontal scaling of processing workers
┌─────────────────┐ ┌─────────────────┐
│ Client App │───▶│ MIMO Server │
└─────────────────┘ └─────────────────┘
│
┌─────────────────┐
│ Mops Service │
└─────────────────┘
│
┌─────────────────┐
│ MongoDB │
└─────────────────┘
│
┌───────────────────────┼───────────────────────┐
▼ ▼ ▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ IngestSplitter │ │ AtomRacer │ │ AtomPuller │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│
┌─────────────────┐
│ FFmpeg Wrapper │
│ - ffprobe │
│ - ffmpeg │
└─────────────────┘
- MIMO Server: gRPC API server handling client requests
- Mops Service: Media operations service managing job lifecycle
- IngestSplitter: Breaks ingestion requests into atomic processing tasks
- AtomRacer: Coordinates and monitors atom processing workers
- AtomPuller: Downloads media from remote sources to local storage
- Go 1.19+
- FFmpeg (for media processing)
- MongoDB (for job persistence)
- Redis (for distributed coordination)
Create a muxfarm.yaml
configuration file:
Muxfarm:
MIMO:
HostName: "localhost"
Port: "50050"
DocumentStore: "mongodb"
MongoDB:
Name: "mongodb"
URI: "mongodb://localhost:27017"
DBName: "muxdb"
DLMRedis:
Name: "redis"
URI: "localhost:6379"
DBNumber: 11
- Start the MIMO server:
./muxfarm mimo
- Start processing workers:
./muxfarm stitch ingestSplitter
./muxfarm stitch atomRacer
MuxFarm exposes a gRPC API for submitting media processing jobs:
// Submit a media processing job
mediain := &plumber.MediaIn{
Input: []*plumber.Media{
{
Storagetype: plumber.StorageType_STORAGE_HTTP,
Uri: "https://example.com/video.mp4",
},
},
Operation: &plumber.Operation{
// Define processing operations
},
}
// Returns a job ID for tracking
jobID, err := client.Ingest(ctx, mediain)
MuxFarm generates streaming-optimized output:
- MPEG-DASH:
.mpd
manifests with segmented media - HLS:
.m3u8
playlists with transport segments - Fragmented MP4: Initialization and media segments
- Multi-bitrate: Adaptive streaming support
The system uses Protocol Buffers for service definitions:
plumber/plumber.proto
: Core service APIfixtures/fixtures.proto
: Data persistence modelsplumber/state.proto
: Job state management
Regenerate protobuf code after changes:
make proto # or protoc commands
Implement the storage interface in plumber/plumber.go
and add the new type to StorageType
enum.
The system tracks job states through MongoDB collections:
ingestCollection
: Top-level ingestion jobsatomCollection
: Individual processing tasks
Job states progress through: STATE_UNSPECIFIED
→ PULL_OK
→ INGEST_OK
MuxFarm is designed to be extensible. Key areas for contribution:
- Additional codec support
- New storage backend integrations
- Enhanced monitoring and observability
- Performance optimizations
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.