Configure PAT and PMT Intervals in FFmpeg MPEG-TS

This article explains how to configure the Program Association Table (PAT) and Program Map Table (PMT) transmission intervals in an MPEG Transport Stream (MPEG-TS) using FFmpeg. You will learn about the specific command-line parameters required to adjust these intervals, allowing you to optimize stream join times, reduce overhead, and comply with strict broadcasting standards.

In an MPEG-TS container, the PAT and PMT are essential tables that a media player must read to identify and decode the audio and video streams. By default, FFmpeg writes these tables into the stream at fixed intervals. However, you can manually control this frequency using the MPEG-TS muxer private options.

The -pat_period_frames Option

FFmpeg controls the PAT and PMT insert interval based on the number of video frames using the -pat_period_frames option.

The default value is 100, meaning FFmpeg inserts a PAT and PMT packet every 100 frames.

To change this interval, use the following syntax:

ffmpeg -i input.mp4 -c:v libx264 -c:a aac -f mpegts -pat_period_frames 50 output.ts

In this example, the PAT/PMT tables will be sent every 50 frames.

Calculating the Time Interval

Because FFmpeg sets the interval in frames rather than milliseconds, you must calculate the value based on your video’s frame rate (fps) to achieve a specific time-based interval.

\[\text{pat\_period\_frames} = \text{Target Interval (seconds)} \times \text{Frame Rate (fps)}\]

Example Configurations:

Configuring SDT Intervals

Along with the PAT and PMT, the Service Description Table (SDT) is also sent periodically. You can adjust its interval using the -sdt_period_frames option in the same manner:

ffmpeg -i input.mp4 -c copy -f mpegts -pat_period_frames 12 -sdt_period_frames 12 output.ts

Why Adjust These Settings?