subhra74/xdm · error
Both period start and duration is missing
Error message
Both period start and duration is missing
What it means
When an MPD contains multiple <Period> elements, CalculatePeriodDurationsIfMissing computes each period's duration from its start/duration attributes. If a period defines neither start nor duration, the duration cannot be derived, so the method throws. This is an invariant check required to compute period boundaries for the segment list.
Solutions
- Add explicit start and/or duration attributes to every Period element in the manifest.
- If you control manifest generation, always emit mediaPresentationDuration plus per-period timing.
- Catch the error and reject the multi-period manifest, directing users to a single-period VOD rendition.
- Check whether the source manifest is actually valid with a DASH validator (e.g. DASH-IF conformance tool).
Example fix
// before <Period id="p2"></Period> // after <Period id="p2" start="PT30S" duration="PT60S"></Period>
Defensive patterns
Strategy: validation
Validate before calling
var doc = new XmlDocument(); doc.LoadXml(mpdXml);
foreach (XmlNode p in doc.SelectNodes("//*[local-name()='Period']"))
if (p.Attributes["start"] == null && p.Attributes["duration"] == null)
throw new Exception("Period missing both start and duration"); Try / catch
try { return MpdParser.Parse(url, null); }
catch (Exception ex) when (ex.Message.Contains("Both period start and duration is missing"))
{ throw new InvalidManifestException("Multi-period MPD lacks timing attributes", ex); } Prevention
- Only feed multi-period manifests with explicit Period@start/@duration
- Fix manifest generation to always emit timing attributes plus mediaPresentationDuration
- Validate multi-period manifests with the DASH-IF tool before use
When it happens
Trigger: Parsing a multi-period MPD (periods.Count > 1) in which at least one Period element lacks both a start attribute and a duration attribute, and the duration can't be inferred from the next period or mediaPresentationDuration.
Common situations: Hand-edited or programmatically generated multi-period manifests missing timing attributes; ad-inserted streams where dynamic periods are added without start times; manifests relying on features (e.g. Period@id continuity / implicit timing) this parser doesn't implement.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
AI-assisted analysis of subhra74/xdm@1ca5a25aae (2026-09-13).
Data as JSON: /api/errors/e94ca58d390c8f63.
Report an issue: GitHub.
Appendix: source
Thrown at app/XDM/XDM.Core/MediaParser/Dash/MpdParser.cs:378
public static IList<long> CalculatePeriodDurationsIfMissing(XmlNodeList periods, long mediaPresentationDuration)
{
var stack = new Stack<XmlNode>();
foreach (XmlNode node in periods)
{
stack.Push(node);
}
var list = new List<long>(periods.Count);
var last = mediaPresentationDuration;
var count = stack.Count;
for (int i = 0; i < count; i++)
{
var node = stack.Pop();
var sduration = node.Attributes["duration"]?.Value;
var sstart = node.Attributes["start"]?.Value;
if (sstart == null && sduration == null)
{
throw new Exception("Both period start and duration is missing");
}
if (sduration != null)
{
var duration = DashUtil.ParseXsDuration(sduration);
list.Add(duration);
last = mediaPresentationDuration - duration;
continue;
}
if (sstart == null && i == stack.Count - 1)
{
sstart = "PT0S";
}
var start = DashUtil.ParseXsDuration(sstart);
list.Add(last - start);
last = start;
}
list.Reverse();
return list;
View on GitHub (pinned to 1ca5a25aae)