Look inside almost any streaming panel and you'll find FFmpeg. It's free, it reads nearly anything, and one command turns a source into a stream. Minimus runs its channels on GStreamer instead, which raises a fair question: isn't FFmpeg better?
For converting video, it often is. For keeping hundreds of live channels on air for months, GStreamer's shape fits better. Here's the difference in practical terms, and why we use both.
Two tools built for different jobs
FFmpeg is a program you give one job to. The command says where to read, what to do with the video and where to send it, something like ffmpeg -i <source> -c copy -f mpegts <output>. It runs that job until the source ends or something stops it, then it exits. It's the standard tool for converting video, and it reads almost every format and codec in use.
GStreamer is a toolkit for building media pipelines inside a program. A pipeline is a chain of small parts, called elements: one reads the source, the next parses it, another keeps time, the last hands the video on. One program can run hundreds of pipelines side by side, each keeping time and each reporting what happens to it. It's at home in things that never end: live streams, video calls, broadcast gear.
Neither is better in general. They're shaped for different work, and a live channel is closer to the work GStreamer was made for.
One process per channel
Most panels start a separate FFmpeg process for every channel. It's simple to build, and it has a real upside: when one of them crashes, only that channel stops.
The costs show up over months, not minutes:
- Every channel is a whole program. Each one carries its own memory, threads and buffers. With hundreds of channels that adds up, and it's where a lot of server memory goes.
- The command is fixed when it starts. To point a channel at another source, you stop the process and start a new one, and players usually have to reconnect.
- Errors arrive as text. When a source fails, FFmpeg writes a line to its log and, usually, exits. To know whether the provider's line was full or the link was dead, the panel has to read that line. Many simply start it again and hope.
What GStreamer does differently
- A channel is a pipeline, not a program. Adding a channel adds a few elements to a program that's already running.
- The video stays inside the program. The end of the pipeline hands each piece of video straight to every viewer of that channel, with no pipe or file in between. The provider sees one connection from the server, whether ten people are watching or several hundred.
- A clock for live video. Each pipeline sends video out at the pace of its own timestamps. A source that arrives in bursts is smoothed out instead of reaching players in bursts that leave them buffering.
- Errors are messages, not exits. When a source fails, the pipeline posts an error with details, including the HTTP status the provider sent. A full line (429, 503 or 509) and a dead link (404 or 403) look different, so the program can treat them differently while every other channel carries on.
- The program holds the viewers, not the pipeline. Because the pipeline lives inside the program, a broken one can be swapped for a new one on the backup source without closing the viewers' connections.
The catch with one program
If every channel lives in one program, a crash anywhere can stop all of them. That's the price of the design, and you have to build around it.
We found GStreamer's HLS reader to be the weak spot: it could crash now and then, and inside one program that stops every channel on the server. That's where FFmpeg comes back in.
GStreamer is also harder to work with. You write code, not a command, and a misbehaving pipeline takes more effort to debug than a line in a shell script. That's probably why so few panels use it.
How Minimus uses both
Minimus runs every channel on GStreamer, and calls on FFmpeg where FFmpeg is the better tool.
- MPEG-TS sources over HTTP go straight through GStreamer: read, parse, pace, share. Nothing is decoded, so a channel costs almost no CPU.
- HLS, DASH, RTMP, RTSP, SRT and files are read by FFmpeg in a small process of its own, which copies the video without converting it and hands it to the GStreamer pipeline. If that FFmpeg crashes, only its channel is rebuilt; every other channel on the server carries on.
- Converting happens in the GStreamer pipeline, on the processor or on a video card, when a source's codecs can't be sent on as they are or when you've set a profile for the channel. Its audio encoder is FFmpeg's, running as a GStreamer element. The two really aren't rivals.
- Created channels play each film or episode through FFmpeg, and GStreamer paces it and shares it with every viewer. FFmpeg also converts an operator's preview when the browser can't play a channel, and reads a film's details when it's added.
- A source that only plays with FFmpeg can have its channel switched to the FFmpeg engine in the channel's settings. Its viewers still share one connection.
When a source fails on a channel that starts on demand, Minimus reads the status in GStreamer's error. A full line is tried again after a short wait, a dead link moves on to the next source, and the new pipeline is slotted in while the viewers stay connected.
Which should you use?
If you're converting files, running batch jobs or need a quick restream of an odd format, use FFmpeg. Nothing is quicker to get going, and it reads almost anything.
If you're running hundreds of live channels for months, each watched by many people at once, with backups that have to take over at 9 pm, you want an engine built on pipelines that live inside one program.
In practice, the answer is usually both, each doing the job it's best at.
| At a glance | GStreamer | FFmpeg |
|---|---|---|
| What it is | A toolkitPipelines inside a program | A programOne job per command |
| A channel is | One pipelineHundreds in one program | One processIts own memory and buffers |
| Changing it while it runs | Replace the pipelineThe program keeps running | Stop itAnd start a new one |
| When a source fails | An error messageWith the HTTP status | A line in its logAnd usually it exits |
| Formats and codecs | ManyFFmpeg's too, through a plugin | Nearly allAlmost every format in use |
| Getting started | CodeMore to learn | One commandQuick to try |
| Best at | Live channelsThat run for months | ConvertingFiles, batch jobs, odd formats |
Whatever your panel runs on, two questions tell you a lot about it. Does a full provider line look different from a dead link? And when a backup source takes over, do your viewers stay connected?