HLS (MPEG-TS) conversion fails with GOP timestamp validation error

Author: Xikee2023Created Sep 23, 2026Updated Sep 23, 2026

Description

When converting certain HLS streams (MPEG-TS segments) to MP4 with Mediabunny, the conversion fails with a GOP timestamp validation error.

This looks related to #321 and #511 (same error message), but in my case the input is an HLS playlist with MPEG-TS segments, not a single MP4 file / trim scenario.

MediaBunny Version: 1.59.0 Test environment: Chrome

Error

Timestamps cannot be smaller than the largest timestamp of the previous GOP (a GOP begins with a key packet and ends right before the next key packet). Got 4092.380711111111s, but largest timestamp is 4092.4157s.

(The absolute timestamps vary by stream; the pattern is that a later packet’s presentation timestamp is slightly smaller than the largest timestamp already seen in the previous GOP. Difference is typically on the order of tens of milliseconds.)

Reproduction

  1. Use Mediabunny Conversion (or equivalent mux path) with an HLS input that uses MPEG-TS segments.
  2. Output to MP4 (packet copy / preferred copy path if applicable).
  3. Conversion fails partway through with the error above.

Minimal code sketch:

typescript
import { Input, Output, Conversion, UrlSource, Mp4OutputFormat, ... } from 'mediabunny';

const input = new Input({
  source:  new UrlSource('https://svip.ryplay14.com/20260829/18783_77a21c85/index.m3u8'),
  formats: /* ... */,
});

const output = new Output({
  format: new Mp4OutputFormat(),
  target: /* ... */,
});

const conversion = await Conversion.init({
  input,
  output
});

await conversion.execute();

The example stream address is: https://svip.ryplay14.com/20260829/18783_77a21c85/index.m3u8. Cross-origin issues may need to be handled during browser testing.

Additionally, I tested this type of stream using hls.js and ffmpeg, and they handled it correctly. Moreover, this is not an isolated case among the many types of HLS streams I've tested. Therefore, I don't think this is a "non-standard" example. MediaBunny would be more complete if it could accommodate this situation. Thanks for your work, bro.