Fragmented MP4: What .m4s Files Are and How to Merge Them

Fragments with .m4s extensions are not broken files. They are valid MP4 pieces missing their header — and the header is the first thing you downloaded and ignored.

Short answer: fragmented MP4 splits an MP4 into an initialisation segment (the container header: track layout, codec parameters, timescale) followed by media fragments (the samples). Neither part plays alone, which is why .m4s files downloaded individually look useless. Merging them is a copy operation — concatenate in manifest order and remux into a single MP4 — and no re-encoding is involved, so nothing about quality changes.

The structure in one paragraph

An ordinary MP4 puts its metadata table near the front or the back and then the media data. A fragmented MP4 instead emits a small init segment carrying the box structure that describes the tracks, then a run of moof + mdat pairs, each describing and containing a short slice of samples. That shape is what makes byte-range requests and adaptive switching cheap, and it is the payload format used by DASH and by HLS in its fMP4 mode. This is why download videos with fragmented MP4 streams always comes with a manifest: the manifest names the init segment and orders the fragments.

How you meet it in practice

  • File names: init.mp4, video-1080-00001.m4s, audio-00001.m4s, or numbered segment-*.m4s.
  • Two families: video fragments and audio fragments are separate — the classic “silent download” when only one family is fetched (missing audio).
  • Multiple rungs: several video directories at different bitrates; the top rung is a choice you make, not a default (choosing quality).

Merging video segments downloaded from a website

1

Keep the init segment and order the rest

Order comes from the manifest, not from filenames — numeric suffixes wrap and lexical order is not playback order. Write out the list before fetching.

2

Concatenate the video track

With a list file, FFmpeg’s concat demuxer joins the fragments, and the init segment supplies the header it needs:

ffmpeg -f concat -safe 0 -i video.txt -c copy video-only.mp4

Its concatenation guide covers both the demuxer and protocol-level forms; container semantics are in the formats documentation.

3

Do the same for audio, then mux together

ffmpeg -i video-only.mp4 -i audio-only.mp4 -c copy -map 0:v -map 1:a final.mp4

Stream copy throughout: the samples are already encoded, so combining them is repackaging, not production.

4

Verify

Play it; check the reported duration against the source, and check for a tail — truncated fragment lists are the most common silent failure. ffprobe final.mp4 should list one video stream and one audio stream.

Convert downloaded web video to MP4 — do you need to?

Fragments are MP4; combining them produces an MP4. So “convert downloaded web video to MP4” usually describes a remux you already did, not an encode. The cases where a real conversion is justified are narrow:

SituationRight action
Fragmented MP4 piecesConcatenate + mux (no encode)
MPEG-TS segments (.ts) from classic HLSRemux to MP4 (no encode) — see HLS to MP4
WebM/VP9 you must open in an H.264-only deviceGenuine transcode — accept the loss, keep the master
File is already .mp4 and playsNothing. A second pass only loses detail

Best format for saving downloaded web videos

Choose by what will read the file, not by fashion:

  • MP4 (H.264 or HEVC + AAC): the safe default. Plays on iPhones, Androids, QuickTime, Windows media apps, most editors, and uploads accept it.
  • MKV: tolerates unusual track layouts — several subtitle tracks, multiple audio languages, or a mix of codec generations in one file. Great on desktop, less universally accepted by mobile players.
  • WebM: what some sources deliver; fine on modern devices, awkward in editors and on Apple platforms without help.

The practical rule: keep the master exactly as delivered, and derive whatever format a specific tool needs. Conversion is a loss, and you want it applied to a copy — see the reasoning in offline viewing on Mac and Windows.

When the merge goes wrong

SymptomCauseFix
File has length but no pictureInit segment missing from the concat listRebuild with the init segment first
Stutters or frozen frames at joinsFragments out of orderOrder from the manifest, not from names
Stops earlyTruncated fragment list (signed URL expired mid-fetch)Re-resolve and fetch the missing tail
SilentAudio family never fetchedFetch audio fragments and mux both
Audio driftsNon-zero start timestampsRegenerate PTS during the mux

FAQ

What is fragmented MP4?

An MP4 split into an init segment carrying the container header plus media fragments carrying samples. It is the payload format of DASH and of HLS in fMP4 mode.

How do I merge video segments downloaded from a website?

List them in manifest order, concatenate with stream copy, do the same for audio, then mux the two into one file.

Why won't my .m4s file play?

Because it lacks the init segment that describes the tracks. Prepend the header and remux rather than trying to open fragments individually.

Do I need to convert fragments to MP4?

No encode is needed: combining init plus fragments with stream copy produces an MP4.

Which is better to save, MP4 or MKV?

MP4 for compatibility; MKV when the source carries multiple subtitle or audio tracks you want to keep in one file.

My merged file is silent — what happened?

You merged only the video family. Fetch the audio fragments as well and mux both streams.