Create Satellite Compliant MPEG-TS Using FFmpeg
This article provides a practical guide on how to configure and run FFmpeg to generate an MPEG-2 Transport Stream (MPEG-TS) optimized for satellite broadcasting. Satellite transmission standards, such as DVB-S and DVB-S2, require strict adherence to specific multiplexing parameters, including constant bitrate (CBR), precise Packet Identifier (PID) mapping, and frequent Program Clock Reference (PCR) insertion. You will learn the exact FFmpeg commands and parameters needed to output a compliant broadcast stream.
The Core Challenges of Satellite MPEG-TS
Satellite receivers (Integrated Receiver-Decoders, or IRDs) require highly stable and predictable streams. Unlike web streaming, where bitrates can fluctuate, satellite transponders operate on a fixed bandwidth. If your stream does not meet the exact bitrate of the allocated satellite slice, the signal will fail.
To achieve satellite compliance, your MPEG-TS container must feature: * Strict Constant Bitrate (CBR): The stream must maintain an identical bitrate at all times using padding (null packets). * Precise PCR Intervals: The Program Clock Reference must be transmitted frequently (typically every 20ms to 40ms) to keep the receiver’s clock synchronized. * Explicit PID Assignment: Video, audio, and metadata packet identifiers must be statically defined so the receiver can decode them without delay.
The FFmpeg Command
Below is the optimized FFmpeg command designed to output a DVB-compliant MPEG-TS stream from a standard MP4 input source.
ffmpeg -i input.mp4 \
-c:v libx264 -b:v 4000k -maxrate:v 4000k -bufsize:v 8000k \
-g 50 -keyint_min 50 -sc_threshold 0 \
-c:a mp2 -b:a 192k -ar 48000 \
-f mpegts \
-mpegts_original_network_id 0x0001 \
-mpegts_transport_stream_id 0x0001 \
-mpegts_service_id 0x0001 \
-mpegts_pmt_start_pid 0x1000 \
-mpegts_start_pid 0x0100 \
-pcr_period 40 \
-muxrate 5000k \
-mpegts_flags +filler \
output.tsParameter Breakdown
To adapt this command to your specific broadcast requirements, you must understand what each parameter does.
1. Video Encoding and GOP Structure
-b:v 4000k -maxrate:v 4000k -bufsize:v 8000k: Constrains the H.264 video encoder to a strict constant bitrate. The buffer size (-bufsize) is set to twice the bitrate to allow the encoder to manage rate control effectively while avoiding buffer underruns on the receiver.-g 50 -keyint_min 50: Sets a fixed Group of Pictures (GOP) size of 50 frames. For 25fps video, this guarantees an I-frame (keyframe) exactly every 2 seconds, which is crucial for fast channel switching on satellite receivers.-sc_threshold 0: Disables scene change detection to prevent the encoder from inserting extra, unscheduled keyframes that would disrupt the GOP structure.
2. Audio Encoding
-c:a mp2 -b:a 192k -ar 48000: Encodes the audio to MPEG-1 Audio Layer II (MP2) at 192 kbps and 48 kHz. While AAC is widely supported, MP2 remains the most universally compatible and resilient audio format for legacy satellite networks.
3. Container and PID Configuration
-f mpegts: Forces the output format to be an MPEG-2 Transport Stream.-mpegts_original_network_id,-mpegts_transport_stream_id,-mpegts_service_id: Sets the network, transport stream, and service IDs. These IDs are read by the receiver to populate the Electronic Program Guide (EPG) and channel lists.-mpegts_pmt_start_pid 0x1000: Sets the Program Map Table (PMT) PID to0x1000(hexadecimal).-mpegts_start_pid 0x0100: Directs FFmpeg to start mapping elementary streams (video and audio) starting at PID0x0100.
4. Multiplexing and Satellite Optimization
-pcr_period 40: Forces the Program Clock Reference to be written every 40 milliseconds. This ensures the satellite receiver stays in sync and prevents AV sync drift.-muxrate 5000k: Sets the absolute total bitrate of the transport stream container to 5 Mbps. This value must be higher than the combined bitrates of your video, audio, and metadata streams (which total roughly 4.2 Mbps in this example).-mpegts_flags +filler: Instructs FFmpeg to insert “filler” (null packets, PID0x1FFF) to pad the stream up to the exact-muxratelimit of 5 Mbps. This creates the rigid, constant bitrate required by satellite modulators.