{"record":{"id":"1ebd4f4de662ff22","repo":"nilaoda/N_m3u8DL-RE","slug":"wvtt-sample-duration-unknown-and-no-default-found","errorCode":null,"errorMessage":"WVTT sample duration unknown, and no default found!","messagePattern":"WVTT sample duration unknown, and no default found!","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/N_m3u8DL-RE.Parser/Mp4/MP4VttUtil.cs","lineNumber":163,"sourceCode":"                                0 + (double)currentTime / timescale);\n                            // Check if same subtitle has been splitted\n                            if (cue != null)\n                            {\n                                var index = cues.FindLastIndex(s => s.EndTime == cue.StartTime && s.Settings == cue.Settings && s.Payload == cue.Payload);\n                                if (index != -1)\n                                {\n                                    cues[index].EndTime = cue.EndTime;\n                                }\n                                else\n                                {\n                                    cues.Add(cue);\n                                }\n                            }\n                        }\n                    }\n                    else\n                    {\n                        throw new Exception(\"WVTT sample duration unknown, and no default found!\");\n                    }\n\n                    if (!(presentation.SampleSize == 0 || totalSize <= presentation.SampleSize))\n                    {\n                        throw new Exception(\"The samples do not fit evenly into the sample sizes given in the TRUN box!\");\n                    }\n\n                } while (presentation.SampleSize != 0 && (totalSize < presentation.SampleSize));\n\n                if (reader.HasMoreData())\n                {\n                    // throw new Exception(\"MDAT which contain VTT cues and non-VTT data are not currently supported!\");\n                }\n            }\n        }\n\n        if (cues.Count > 0)\n        {","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/nilaoda/N_m3u8DL-RE/blob/e113dee70c924ee08dae5460624909b04d84cb76/src/N_m3u8DL-RE.Parser/Mp4/MP4VttUtil.cs#L145-L181","documentation":"While decoding WVTT samples, ExtractSub determines each sample's duration from the TRUN per-sample duration, an explicit 'tfdt'/sample timing, or the TFHD defaultSampleDuration. If none of these provided a duration, the cue timing cannot be computed, so it throws this error.","triggerScenarios":"The segment's trun box omits per-sample durations, no tfdt box supplied timing, and the tfhd box has no defaultSampleDuration — the loop reaches a presentation with unknown duration and no default.","commonSituations":"Minimally muxed fragments produced by custom packagers that strip default durations from tfhd; hand-crafted or edited MP4 fragments; packagers that always rely on trun durations but the flags were misparsed.","solutions":["Re-mux the segment with ffmpeg/Shaka packager so tfhd includes defaultSampleDuration.","Ensure trun flags include sample-duration (0x000100) so per-sample durations are present.","Verify the tfhd flags actually contain the default-sample-duration bit (0x000008) in the segment.","Patch MP4VttUtil to supply a fallback default duration from the container/movie header."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// confirm the init/segment provides timing: tfhd with default-sample-duration or trun with sample-duration\nbool HasTimingInfo(byte[] seg) =>\n    Mp4BoxScanner.Find(seg, \"tfdt\") != null ||\n    (Mp4BoxScanner.Find(seg, \"tfhd\") is { } t && (t.Flags & 0x000008) != 0) ||\n    (Mp4BoxScanner.Find(seg, \"trun\") is { } r && (r.Flags & 0x000100) != 0);","typeGuard":null,"tryCatchPattern":"try { var subs = MP4VttUtil.ExtractSub(dataSeg, baseTime); }\ncatch (Exception ex) when (ex.Message.Contains(\"duration unknown\")) {\n    logger.Warn(\"No sample duration in fragment; falling back to default cue duration\");\n    subs = ExtractWithDefaultDuration(dataSeg, TimeSpan.FromSeconds(2));\n}","preventionTips":["Ensure init segments declare defaultSampleDuration in tfhd.","Use packagers that emit per-sample durations in trun.","Test subtitle fragments from each new stream source for timing fields.","Prefer well-known muxers for WVTT content."],"tags":["mp4","subtitles","timing"],"backgroundTag":"missing-required-argument","analyzedSha":"e113dee70c924ee08dae5460624909b04d84cb76","analyzedAt":"2026-09-13T02:43:21.078Z","contentChangedAt":"2026-09-13T02:43:21.078Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}