ts
The 'ts' directive configures a location for receiving MPEG-TS streams over HTTP.
Description
The 'ts' directive is essential for setting up live streaming of MPEG-TS (MPEG Transport Stream) video content over HTTP in an NGINX server. When enabled in a location block, it allows the server to accept MPEG-TS data from clients such as streaming tools or encoders. The last component of the requested URI is interpreted as the stream name used for managing the stream during live playback. For example, in a request to http://server/foo/bar/baz, the segment 'baz' is identified as the stream name.
This directive plays a crucial role when combined with other directives, like 'ts_hls' for HLS (HTTP Live Streaming) or 'ts_dash' for MPEG-DASH, enabling the server to provide playlists and segments required for adaptive bitrate streaming. For optimal performance and removal of limitations regarding HTTP request body size, it is advisable to configure the client_max_body_size directive to 0, allowing unlimited body sizes to ensure smooth live streaming. Furthermore, the request body is processed using an internal handler that initializes the streaming context for subsequent operations, such as segment creation and management.
Config Example
location /stream/ {
ts;
ts_hls path=/var/hls segment=5s;
}Ensure the last URI component is unique and serves as the stream name to avoid collisions.
Make sure to set 'client_max_body_size' to '0' to prevent truncation of large payloads during live streaming.
Be aware that without 'ts_hls' or 'ts_dash', the 'ts' directive alone does not serve content; it needs complementary directives to work effectively.