← Blog.backToBlog

TS Segments Explained: How HLS Downloading & Merging Works

7 min read

What Are TS Segments?

An HLS stream isn't one video file — it's split into many small pieces called segments. Each is typically a .ts (MPEG Transport Stream) file holding 2–10 seconds of video, though newer streams use fragmented MP4 (.m4s). A ten-minute video might be 60–120 segments. Splitting video this way is what lets HLS stream reliably over HTTP and adapt quality on the fly — but it also means downloading requires reassembling the pieces.

How the M3U8 Playlist Orders Segments

The .m3u8 playlist is the map. It lists each segment's URL in playback order, along with its duration (EXTINF) and any encryption info (EXT-X-KEY). A downloader reads this list to know which files to fetch and in what order to join them. Get the order wrong and the video is scrambled — which is why you can't just concatenate segments randomly.

How Downloaders Merge Segments

Every M3U8 downloader follows the same three steps:

  1. Parse the playlist — read the ordered list of segment URLs.
  2. Download the segments — often many in parallel for speed, with retries for failures.
  3. Concatenate in order — join the bytes into one continuous stream, decrypting first if the segments are encrypted.

Our M3U8 downloader does all three automatically, in your browser.

Merging TS Files Manually With FFmpeg

If you already have the .ts files, FFmpeg can merge them. Create a text file listing them, then:

ffmpeg -f concat -safe 0 -i list.txt -c copy output.mp4

where list.txt contains lines like file 'segment1.ts'. The -c copy flag joins them without re-encoding, so it's fast and lossless. This is exactly what a downloader automates for you.

TS vs. fMP4 Segments

Two segment formats exist. .ts (MPEG-TS) is the classic HLS format, widely compatible. fMP4 (.m4s) is the newer fragmented-MP4 format, required for HEVC and used by low-latency HLS. Both merge into a single file the same way conceptually; a good downloader handles either.

Handling Encrypted Segments

Many streams encrypt segments with AES-128. The playlist's EXT-X-KEY tag points to a key file. Before merging, each segment must be decrypted with that key. As long as the key URL is reachable, a downloader handles this transparently. DRM-protected streams use stronger encryption that generic tools can't decrypt.

Why Merging Exists

HLS splits media into many segments so players can ABR-switch and seek efficiently. Humans usually want one file. Merging concatenates those segments in order, optionally decrypting AES-128 first. Without merge, you have a folder of parts — not a usable lecture archive.

Online downloaders automate merge: downloader. FFmpeg can concat demuxer or remux to MP4: FFmpeg guide.

Merge vs Remux vs Re-encode

StepWhat changes
Merge segmentsMany files → one elementary stream blob
RemuxContainer (e.g. to MP4), codecs kept
Re-encodeCodecs/bitrate/resolution

Do not re-encode “for merge.” Merge first; remux if editors need MP4; re-encode only with intent. Converter: converter.

Failure Modes During Merge

Missing segment → gap or abort. Wrong order → glitches. Key rotation failures → decrypt errors. Live window → incomplete show. Use retry-capable tools and verify duration after merge. Help: download failed.

Practical Checklist

Before you close the tab: confirm the URL still returns 200, the tool finished without a forced account wall, and the result plays in a second app. Keep a short authorized sample for regression after CDN changes. Rights still apply — free tools do not create free rights.

Related Tools on This Site

Use the online player to preflight, the downloader to merge segments, and the converter when you need a portable MP4. Prefer client-side paths when CORS allows; fall back to FFmpeg when the browser is blocked.

Common Mistakes to Avoid

Do not chain three random free websites for the same job — each re-encode costs quality and raises watermark risk. Do not ignore 403/CORS as “player bugs.” Do not archive paywalled DRM catalogs. Document the one path that worked so your team does not rediscover failures under deadline pressure.

Notes for Operators

Write the successful command or UI path into your runbook with the date and the CDN hostname. Future incidents then start with a known-good baseline instead of a blank search box. Re-test after certificate, token, or edge-rule changes.

Bottom Line

Use the free browser path for quick authorized work, keep a desktop escape hatch for CORS and long jobs, and never confuse “the tool worked” with “you have the rights.” Document the path that succeeds so your team stops rediscovering the same failure under deadline pressure. Start with the matching tool page on this site, then fall back to FFmpeg when the browser cannot complete the job.

Frequently Asked Questions

What is a TS segment?
A small 2–10 second chunk of an HLS video, listed in the M3U8 playlist.

How do I merge TS files?
Use an M3U8 downloader, or FFmpeg's concat mode with -c copy.

Why must segments be in order?
Joining them out of order scrambles the video.

Can encrypted segments be merged?
Yes, if the AES-128 key is reachable; DRM cannot.