{"id":497637,"date":"2026-10-06T21:20:22","date_gmt":"2026-10-06T18:20:22","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=497637"},"modified":"2026-10-06T21:20:22","modified_gmt":"2026-10-06T18:20:22","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=497637","title":{"rendered":"\u041a\u0430\u043a \u0443\u0437\u043d\u0430\u0442\u044c \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u0438\u0434\u0435\u043e \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435, \u0441\u043a\u0430\u0447\u0430\u0432 7% \u0444\u0430\u0439\u043b\u0430, \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435 MP4 \u0431\u044b\u0432\u0430\u0435\u0442 \u043d\u043e\u043b\u044c"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043b \u0440\u043e\u043b\u0438\u043a \u043d\u0430 37 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u043e\u0442\u0432\u0435\u0442: \u00ab\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u0438\u0434\u0435\u043e\u00bb. \u0420\u043e\u043b\u0438\u043a \u0431\u044b\u043b \u043e\u0431\u044b\u0447\u043d\u044b\u0439, \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u043b\u0441\u044f \u0432 \u043b\u044e\u0431\u043e\u043c \u043f\u043b\u0435\u0435\u0440\u0435, ffprobe \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u043b 18 \u0441\u0435\u043a\u0443\u043d\u0434. \u0412 \u043b\u043e\u0433\u0430\u0445 \u043e\u0448\u0438\u0431\u043e\u043a \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435 \u0431\u044b\u043b\u043e \u0432\u043e\u043e\u0431\u0449\u0435. \u041f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c \u0440\u0430\u0437\u0431\u043e\u0440 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432 MP4, \u043f\u043e\u0447\u0435\u043c\u0443 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435 \u0444\u0430\u0439\u043b\u0430 \u043e\u043d\u0430 \u0431\u044b\u0432\u0430\u0435\u0442 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0438 \u043a\u0430\u043a \u0434\u043e\u0441\u0442\u0430\u0442\u044c \u0435\u0451 \u0442\u0440\u0435\u043c\u044f HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u0431\u0435\u0437 ffmpeg.<\/p>\n<h3>\u0417\u0430\u0447\u0435\u043c \u043c\u0435\u0440\u0438\u0442\u044c \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435<\/h3>\n<p>\u042f \u0434\u0435\u043b\u0430\u044e Aigena, \u0441\u0435\u0440\u0432\u0438\u0441, \u0433\u0434\u0435 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442 \u0438 \u043f\u0440\u0430\u0432\u044f\u0442 \u0432\u0438\u0434\u0435\u043e. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0442\u0430\u043c \u0441\u0442\u043e\u0438\u0442 \u0434\u0435\u043d\u0435\u0433 \u0437\u0430 \u043a\u0430\u0436\u0434\u0443\u044e \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u0440\u043e\u043b\u0438\u043a\u0430. \u0414\u043e\u043b\u0433\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u043b \u0431\u0440\u0430\u0443\u0437\u0435\u0440: \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043b \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u0430, \u043f\u043e\u043b\u043e\u0436\u0438\u043b \u0447\u0438\u0441\u043b\u043e \u0432 \u0437\u0430\u043f\u0440\u043e\u0441. \u0421\u0435\u0440\u0432\u0435\u0440 \u044d\u0442\u043e\u043c\u0443 \u0447\u0438\u0441\u043b\u0443 \u0432\u0435\u0440\u0438\u043b.<\/p>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u0430 \u0437\u0430\u0434\u043d\u0438\u043c \u0447\u0438\u0441\u043b\u043e\u043c. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443 \u0440\u043e\u043b\u0438\u043a \u0443\u0445\u043e\u0434\u0438\u0442 \u0446\u0435\u043b\u0438\u043a\u043e\u043c, \u0430 \u0441\u0447\u0451\u0442 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u0447\u0438\u0441\u043b\u0443 \u0438\u0437 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u041e\u0442\u043f\u0440\u0430\u0432\u0438\u043b <code>duration: 1<\/code> \u0434\u043b\u044f \u043f\u044f\u0442\u0438\u043c\u0438\u043d\u0443\u0442\u043d\u043e\u0433\u043e \u0432\u0438\u0434\u0435\u043e, \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u043f\u044f\u0442\u044c \u043c\u0438\u043d\u0443\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u043e \u0446\u0435\u043d\u0435 \u043e\u0434\u043d\u043e\u0439 \u0441\u0435\u043a\u0443\u043d\u0434\u044b. \u041f\u043b\u0430\u0442\u0438\u043b \u0431\u044b \u0437\u0430 \u044d\u0442\u043e \u044f.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0434\u043e \u043c\u0435\u0440\u0438\u0442\u044c \u0441\u0430\u043c\u043e\u043c\u0443, \u043f\u043e \u0444\u0430\u0439\u043b\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0436\u0435 \u043b\u0435\u0436\u0438\u0442 \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435.<\/p>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0432 \u0433\u043e\u043b\u043e\u0432\u0443: ffprobe. \u041e\u043d \u0443\u043c\u0435\u0435\u0442 \u0447\u0438\u0442\u0430\u0442\u044c \u043f\u043e HTTP \u0438 \u0441\u0430\u043c \u0434\u0435\u043b\u0430\u0435\u0442 range-\u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442. \u042f \u0435\u0433\u043e \u043d\u0435 \u0432\u0437\u044f\u043b \u043f\u043e \u0434\u0432\u0443\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c. \u041d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u0441\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0434\u0435\u043d\u0435\u0433. \u0418 \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0442\u0430\u0449\u0438\u0442\u044c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a \u0440\u0430\u0434\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u0435, \u043a\u0430\u043a \u043c\u043d\u0435 \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u043b\u0435\u0436\u0438\u0442 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435 \u0444\u0430\u0439\u043b\u0430 \u043d\u0430 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435.<\/p>\n<p>\u041f\u0440\u043e \u00ab\u043d\u0430 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435\u00bb \u044f \u043e\u0448\u0438\u0431\u0430\u043b\u0441\u044f, \u043d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u043d\u0438\u0436\u0435.<\/p>\n<h3>MP4 \u0437\u0430 \u0434\u0432\u0435 \u043c\u0438\u043d\u0443\u0442\u044b<\/h3>\n<p>\u0424\u0430\u0439\u043b MP4 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0431\u043e\u043a\u0441\u043e\u0432. \u0423 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0431\u043e\u043a\u0441\u0430 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0447\u0435\u0442\u044b\u0440\u0435 \u0431\u0430\u0439\u0442\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0438 \u0447\u0435\u0442\u044b\u0440\u0435 \u0431\u0430\u0439\u0442\u0430 \u0438\u043c\u0435\u043d\u0438: <code>ftyp<\/code>, <code>moov<\/code>, <code>mdat<\/code> \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u0411\u043e\u043a\u0441\u044b \u0432\u043b\u043e\u0436\u0435\u043d\u044b \u0434\u0440\u0443\u0433 \u0432 \u0434\u0440\u0443\u0433\u0430, \u043a\u0430\u043a \u043f\u0430\u043f\u043a\u0438.<\/p>\n<p>\u0412\u0441\u0451, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043e \u0440\u043e\u043b\u0438\u043a\u0435, \u043b\u0435\u0436\u0438\u0442 \u0432 <code>moov<\/code>. \u0412\u043d\u0443\u0442\u0440\u0438 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c <code>mvhd<\/code>, \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0444\u0438\u043b\u044c\u043c\u0430, \u0430 \u0432 \u043d\u0451\u043c \u0434\u0432\u0430 \u043f\u043e\u043b\u044f: <code>timescale<\/code>, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0438\u043a\u043e\u0432 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0435, \u0438 <code>duration<\/code>, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0438\u043a\u043e\u0432 \u0434\u043b\u0438\u0442\u0441\u044f \u0440\u043e\u043b\u0438\u043a. \u0414\u0435\u043b\u0438\u043c \u043e\u0434\u043d\u043e \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0435 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0435\u043a\u0443\u043d\u0434\u044b.<\/p>\n<p>\u0422\u043e\u043d\u043a\u043e\u0441\u0442\u044c \u043e\u0434\u043d\u0430: <code>moov<\/code> \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u043e\u044f\u0442\u044c \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0444\u0430\u0439\u043b\u0430 \u0438\u043b\u0438 \u0432 \u043a\u043e\u043d\u0446\u0435. \u0415\u0441\u043b\u0438 \u0440\u043e\u043b\u0438\u043a \u0433\u043e\u0442\u043e\u0432\u0438\u043b\u0438 \u0434\u043b\u044f \u0432\u0435\u0431\u0430, \u0442\u043e \u0432 \u043d\u0430\u0447\u0430\u043b\u0435. \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0438\u0437 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430, \u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u0432\u0441\u0435\u0445 \u043c\u0435\u0434\u0438\u0430\u0434\u0430\u043d\u043d\u044b\u0445, \u0432 \u0445\u0432\u043e\u0441\u0442\u0435.<\/p>\n<p>\u041e\u0442\u0441\u044e\u0434\u0430 \u043f\u0435\u0440\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f. \u041f\u0440\u043e\u0441\u0438\u043c \u0443 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u043f\u0435\u0440\u0432\u044b\u0435 256 \u043a\u0438\u043b\u043e\u0431\u0430\u0439\u0442. \u041d\u0435 \u043d\u0430\u0448\u043b\u0438 <code>mvhd<\/code>, \u043f\u0440\u043e\u0441\u0438\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0434\u0432\u0430 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442\u0430.<\/p>\n<pre><code class=\"javascript\">async function fetchRange(url, range) {  try {    const res = await fetch(url, {      headers: { Range: range },      signal: AbortSignal.timeout(15_000),    });    if (!res.ok) return null;    return Buffer.from(await res.arrayBuffer());  } catch {    return null;  }}\/\/ mvhd: version(1) flags(3) created modified timescale(4) duration\/\/ \u0412 \u0432\u0435\u0440\u0441\u0438\u0438 0 \u0434\u0430\u0442\u044b \u0438 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u043e 4 \u0431\u0430\u0439\u0442\u0430, \u0432 \u0432\u0435\u0440\u0441\u0438\u0438 1 \u043f\u043e 8.function parseMvhd(buf) {  const idx = buf.indexOf(\"mvhd\", 0, \"latin1\");  if (idx &lt; 0) return null;  const p = idx + 4;  if (buf[p] === 1) {    if (p + 32 &gt; buf.length) return null;    const timescale = buf.readUInt32BE(p + 20);    const duration = Number(buf.readBigUInt64BE(p + 24));    return timescale &gt; 0 ? duration \/ timescale : null;  }  if (p + 20 &gt; buf.length) return null;  const timescale = buf.readUInt32BE(p + 12);  const duration = buf.readUInt32BE(p + 16);  return timescale &gt; 0 ? duration \/ timescale : null;}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper\"><\/span><\/a><\/div><\/pre>\n<p>\u0422\u0440\u0438\u0434\u0446\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 \u0432\u0441\u0451\u043c, \u0447\u0442\u043e \u044f \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u043b \u0441\u0430\u043c. \u0412\u044b\u043a\u0430\u0442\u0438\u043b \u0438 \u0437\u0430\u0431\u044b\u043b.<\/p>\n<h3>\u0427\u0442\u043e \u0441\u043b\u043e\u043c\u0430\u043b\u043e\u0441\u044c<\/h3>\n<p>\u0422\u0440\u0435\u0442\u044c\u0435\u0433\u043e \u043e\u043a\u0442\u044f\u0431\u0440\u044f \u043f\u0440\u0438\u0448\u0451\u043b \u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 \u0440\u043e\u043b\u0438\u043a \u043d\u0430 37 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442. \u0421\u0435\u0440\u0432\u0435\u0440 \u043e\u0442\u0432\u0435\u0442\u0438\u043b \u043e\u0442\u043a\u0430\u0437\u043e\u043c \u0435\u0449\u0451 \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u043b \u0437\u0430\u043f\u0438\u0441\u044c \u043e \u0437\u0430\u0434\u0430\u0447\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u043e\u0448\u0438\u0431\u043e\u043a \u0435\u0433\u043e \u043d\u0435 \u0431\u044b\u043b\u043e. \u0427\u0435\u043b\u043e\u0432\u0435\u043a \u0432\u0438\u0434\u0435\u043b \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435, \u044f \u043d\u0435 \u0432\u0438\u0434\u0435\u043b \u043d\u0438\u0447\u0435\u0433\u043e.<\/p>\n<p>\u042f \u0441\u043a\u0430\u0447\u0430\u043b \u0444\u0430\u0439\u043b \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u043b, \u0447\u0442\u043e \u0432 \u043d\u0451\u043c. <code>mvhd<\/code> \u043d\u0430 \u043c\u0435\u0441\u0442\u0435, \u0432 \u043f\u0435\u0440\u0432\u044b\u0445 \u043a\u0438\u043b\u043e\u0431\u0430\u0439\u0442\u0430\u0445. <code>timescale<\/code> \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439. <code>duration<\/code> \u0440\u0430\u0432\u0435\u043d \u043d\u0443\u043b\u044e.<\/p>\n<p>\u041d\u0435 \u043c\u0443\u0441\u043e\u0440, \u043d\u0435 \u043e\u0431\u0440\u0435\u0437\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b. \u0427\u0435\u0441\u0442\u043d\u044b\u0439 \u043d\u043e\u043b\u044c, \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u043c, \u043a\u0442\u043e \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0441\u043e\u0437\u0434\u0430\u043b.<\/p>\n<p>\u042d\u0442\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 MP4. \u0412 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u0432\u0441\u0435 \u043a\u0430\u0434\u0440\u044b, \u0430 \u0432 \u043a\u043e\u043d\u0446\u0435, \u043a\u043e\u0433\u0434\u0430 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0443\u0436\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430, \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438. \u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u0438\u0448\u0435\u0442\u0441\u044f \u043f\u043e-\u0434\u0440\u0443\u0433\u043e\u043c\u0443: \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0441\u0440\u0430\u0437\u0443, \u0430 \u043f\u043e\u0442\u043e\u043c \u043a\u0443\u0441\u043a\u0438 \u043f\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u043a\u0443\u043d\u0434, \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u043e \u0441\u0432\u043e\u0438\u043c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u043c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u043c <code>moof<\/code>. \u0422\u0430\u043a \u0443\u0434\u043e\u0431\u043d\u043e \u0441\u0442\u0440\u0438\u043c\u0438\u0442\u044c \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u043b\u0435\u0442\u0443: \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u043e\u0431\u043e\u0440\u0432\u0451\u0442\u0441\u044f, \u0443\u0436\u0435 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u043a\u0443\u0441\u043a\u0438 \u043e\u0441\u0442\u0430\u043d\u0443\u0442\u0441\u044f \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u043c\u0438.<\/p>\n<p>\u0426\u0435\u043d\u0430 \u044d\u0442\u043e\u0433\u043e \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u0437\u0430\u043f\u0438\u0441\u0438 \u0433\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0435\u0449\u0451 \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430. \u0418 \u0442\u0443\u0434\u0430 \u043f\u0438\u0448\u0443\u0442 \u043d\u043e\u043b\u044c.<\/p>\n<p>\u0412\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<pre><code class=\"bash\">ffmpeg -i input.mp4 -c copy -movflags frag_keyframe+empty_moov frag.mp4<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u042f \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u0440\u043e\u043b\u0438\u043a\u0435 \u0432 18 \u0441\u0435\u043a\u0443\u043d\u0434. \u0412 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0431\u043e\u043a\u0441\u044b \u0438\u0434\u0443\u0442 \u0442\u0430\u043a: <code>ftyp<\/code>, <code>free<\/code>, <code>mdat<\/code>, <code>moov<\/code>, \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432 <code>mvhd<\/code> \u0440\u0430\u0432\u043d\u0430 18000. \u0412\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c: <code>ftyp<\/code>, <code>moov<\/code>, \u043f\u043e\u0442\u043e\u043c \u043f\u0430\u0440\u044b <code>moof<\/code> \u0438 <code>mdat<\/code>, \u0432 \u0441\u0430\u043c\u043e\u043c \u043a\u043e\u043d\u0446\u0435 <code>mfra<\/code>. \u0414\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432 <code>mvhd<\/code> \u0440\u0430\u0432\u043d\u0430 \u043d\u0443\u043b\u044e. ffprobe \u043d\u0430 \u043e\u0431\u043e\u0438\u0445 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 18 \u0441\u0435\u043a\u0443\u043d\u0434, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d \u0447\u0438\u0442\u0430\u0435\u0442 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b, \u0430 \u043d\u0435 \u0432\u0435\u0440\u0438\u0442 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0443.<\/p>\n<h3>\u0413\u0434\u0435 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043b\u0435\u0436\u0438\u0442 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435<\/h3>\n<p>\u0420\u0430\u0437 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u043c\u043e\u043b\u0447\u0438\u0442, \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0434\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0438\u0437 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043e\u0432. \u0427\u0438\u0442\u0430\u0442\u044c \u0432\u0441\u0435 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u043f\u043e\u0434\u0440\u044f\u0434 \u0437\u043d\u0430\u0447\u0438\u0442 \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0432\u0435\u0441\u044c \u0444\u0430\u0439\u043b, \u0430 \u044d\u0442\u043e\u0433\u043e \u044f \u0438 \u0445\u043e\u0442\u0435\u043b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c. \u041d\u0443\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439: \u0432\u0440\u0435\u043c\u044f \u0435\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043b\u044e\u0441 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0435\u0433\u043e \u043a\u0430\u0434\u0440\u043e\u0432 \u0438 \u0435\u0441\u0442\u044c \u043a\u043e\u043d\u0435\u0446 \u0440\u043e\u043b\u0438\u043a\u0430.<\/p>\n<p>\u041d\u0430\u0439\u0442\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0431\u043e\u043a\u0441 <code>mfra<\/code> \u0432 \u0445\u0432\u043e\u0441\u0442\u0435 \u0444\u0430\u0439\u043b\u0430. \u042d\u0442\u043e \u043e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435: \u0432 \u043d\u0451\u043c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0434\u043e\u0440\u043e\u0436\u043a\u0438 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043e, \u0441 \u043a\u0430\u043a\u043e\u0433\u043e \u0431\u0430\u0439\u0442\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442.<\/p>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u043f\u043e \u0446\u0435\u043f\u043e\u0447\u043a\u0435:<\/p>\n<ol>\n<li>\n<p>\u0418\u0437 <code>moov<\/code> \u0431\u0435\u0440\u0451\u043c <code>timescale<\/code> \u043a\u0430\u0436\u0434\u043e\u0439 \u0434\u043e\u0440\u043e\u0436\u043a\u0438 (\u0431\u043e\u043a\u0441 <code>mdhd<\/code>) \u0438 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a\u0430\u0434\u0440\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e (\u0431\u043e\u043a\u0441 <code>trex<\/code>).<\/p>\n<\/li>\n<li>\n<p>\u0418\u0437 <code>mfra<\/code> \u0431\u0435\u0440\u0451\u043c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0422\u0440\u0435\u0442\u044c\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u0447\u0438\u0442\u0430\u0435\u043c 256 \u043a\u0438\u043b\u043e\u0431\u0430\u0439\u0442 \u0441 \u044d\u0442\u043e\u0433\u043e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f. \u0421\u0430\u043c <code>moof<\/code> \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439, \u043a\u0430\u0434\u0440\u044b \u0438\u0437 <code>mdat<\/code> \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u044b.<\/p>\n<\/li>\n<li>\n<p>\u0412 <code>moof<\/code> \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0434\u043e\u0440\u043e\u0436\u043a\u0438 \u0435\u0441\u0442\u044c <code>tfdt<\/code>, \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430, \u0438 <code>trun<\/code>, \u0441\u043f\u0438\u0441\u043e\u043a \u043a\u0430\u0434\u0440\u043e\u0432. \u0421\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043a\u0430\u0434\u0440\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>\u0414\u0435\u043b\u0438\u043c \u043d\u0430 <code>timescale<\/code>. \u0411\u0435\u0440\u0451\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u043f\u043e \u0434\u043e\u0440\u043e\u0436\u043a\u0430\u043c.<\/p>\n<\/li>\n<\/ol>\n<p>\u041d\u0430 \u0442\u043e\u043c \u0440\u043e\u043b\u0438\u043a\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0442\u0430\u043a: \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430 536536, \u0432 \u043d\u0451\u043c \u0447\u0435\u0442\u044b\u0440\u0435 \u043a\u0430\u0434\u0440\u0430 \u043f\u043e 1001 \u0442\u0438\u043a\u0443, \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0435 30000 \u0442\u0438\u043a\u043e\u0432. (536536 + 4 \u00d7 1001) \/ 30000 = 18,018 \u0441\u0435\u043a\u0443\u043d\u0434\u044b.<\/p>\n<p>\u0422\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430: 256 \u041a\u0411, 2 \u041c\u0411 \u0438 \u0435\u0449\u0451 256 \u041a\u0411. \u041e\u043a\u043e\u043b\u043e \u0434\u0432\u0443\u0445 \u0441 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u043e\u0439 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442 \u0438\u0437 \u0442\u0440\u0438\u0434\u0446\u0430\u0442\u0438 \u0441\u0435\u043c\u0438.<\/p>\n<h3>\u041a\u043e\u0434<\/h3>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0431\u0449\u0438\u0439 \u0440\u0430\u0437\u0431\u043e\u0440 \u0431\u043e\u043a\u0441\u043e\u0432. \u0420\u0430\u0437\u043c\u0435\u0440 1 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u043b\u0435\u0436\u0438\u0442 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0432\u043e\u0441\u044c\u043c\u0438 \u0431\u0430\u0439\u0442\u0430\u0445, \u0440\u0430\u0437\u043c\u0435\u0440 0 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u00ab\u0434\u043e \u043a\u043e\u043d\u0446\u0430 \u0444\u0430\u0439\u043b\u0430\u00bb.<\/p>\n<pre><code class=\"javascript\">function boxes(buf, start = 0, end = buf.length) {  const result = [];  for (let p = start; p + 8 &lt;= end; ) {    let size = buf.readUInt32BE(p);    let header = 8;    if (size === 1) {      if (p + 16 &gt; end) break;      size = Number(buf.readBigUInt64BE(p + 8));      header = 16;    } else if (size === 0) size = end - p;    if (!Number.isSafeInteger(size) || size &lt; header || p + size &gt; end) break;    result.push({      type: buf.toString(\"latin1\", p + 4, p + 8),      start: p,      payload: p + header,      end: p + size,    });    p += size;  }  return result;}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0414\u043e\u0440\u043e\u0436\u043a\u0438: \u043d\u043e\u043c\u0435\u0440 \u0438\u0437 <code>tkhd<\/code>, <code>timescale<\/code> \u0438\u0437 <code>mdhd<\/code>, \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a\u0430\u0434\u0440\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438\u0437 <code>trex<\/code>.<\/p>\n<pre><code class=\"javascript\">function fragmentTracks(head) {  const tracks = new Map();  const moov = boxes(head).find((b) =&gt; b.type === \"moov\");  if (!moov) return tracks;  const children = boxes(head, moov.payload, moov.end);  for (const trak of children.filter((b) =&gt; b.type === \"trak\")) {    const inner = boxes(head, trak.payload, trak.end);    const tkhd = inner.find((b) =&gt; b.type === \"tkhd\");    const mdia = inner.find((b) =&gt; b.type === \"mdia\");    const mdhd = mdia &amp;&amp; boxes(head, mdia.payload, mdia.end).find((b) =&gt; b.type === \"mdhd\");    if (!tkhd || !mdhd) continue;    \/\/ \u0412 \u0432\u0435\u0440\u0441\u0438\u0438 1 \u0434\u0430\u0442\u044b \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442 \u043f\u043e 8 \u0431\u0430\u0439\u0442, \u043f\u043e\u043b\u044f \u0441\u0434\u0432\u0438\u0433\u0430\u044e\u0442\u0441\u044f.    const idAt = tkhd.payload + (head[tkhd.payload] === 1 ? 20 : 12);    const scaleAt = mdhd.payload + (head[mdhd.payload] === 1 ? 20 : 12);    if (idAt + 4 &gt; tkhd.end || scaleAt + 4 &gt; mdhd.end) continue;    const timescale = head.readUInt32BE(scaleAt);    if (timescale) tracks.set(head.readUInt32BE(idAt), { timescale, defaultDuration: 0 });  }  const mvex = children.find((b) =&gt; b.type === \"mvex\");  if (mvex) {    for (const trex of boxes(head, mvex.payload, mvex.end).filter((b) =&gt; b.type === \"trex\")) {      if (trex.payload + 16 &gt; trex.end) continue;      const track = tracks.get(head.readUInt32BE(trex.payload + 4));      if (track) track.defaultDuration = head.readUInt32BE(trex.payload + 12);    }  }  return tracks;}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0421\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430 \u0438\u0437 <code>mfra<\/code>. \u0417\u0430\u043f\u0438\u0441\u0438 \u0432 <code>tfra<\/code> \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b: \u0442\u0440\u0438 \u0434\u0432\u0443\u0445\u0431\u0438\u0442\u043d\u044b\u0445 \u043f\u043e\u043b\u044f \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435 \u0433\u043e\u0432\u043e\u0440\u044f\u0442, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0430\u0439\u0442 \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442 \u043d\u043e\u043c\u0435\u0440\u0430, \u043f\u043b\u044e\u0441 \u0432\u0440\u0435\u043c\u044f \u0438 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043f\u043e 4 \u0438\u043b\u0438 8 \u0431\u0430\u0439\u0442.<\/p>\n<pre><code class=\"javascript\">function tailBox(buf, type) {  for (let at = buf.lastIndexOf(type); at &gt;= 4; at = buf.lastIndexOf(type, at - 1)) {    const size = buf.readUInt32BE(at - 4);    if (size &gt;= 8 &amp;&amp; at - 4 + size &lt;= buf.length) {      return { type, start: at - 4, payload: at + 4, end: at - 4 + size };    }  }}function lastFragmentOffset(tail) {  const mfra = tailBox(tail, \"mfra\");  if (!mfra) return null;  let last = -1;  for (const tfra of boxes(tail, mfra.payload, mfra.end).filter((b) =&gt; b.type === \"tfra\")) {    const p = tfra.payload;    if (p + 16 &gt; tfra.end) continue;    const wide = tail[p] === 1;    const lengths = tail.readUInt32BE(p + 8);    const count = tail.readUInt32BE(p + 12);    const width =      (wide ? 16 : 8) + ((lengths &gt;&gt; 4) &amp; 3) + ((lengths &gt;&gt; 2) &amp; 3) + (lengths &amp; 3) + 3;    const end = p + 16 + count * width;    if (!count || end &gt; tfra.end) continue;    const offsetAt = end - width + (wide ? 8 : 4);    const offset = wide ? Number(tail.readBigUInt64BE(offsetAt)) : tail.readUInt32BE(offsetAt);    if (Number.isSafeInteger(offset)) last = Math.max(last, offset);  }  return last &gt;= 0 ? last : null;}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0418 \u0441\u0430\u043c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442. \u0424\u043b\u0430\u0433\u0438 \u0432 <code>tfhd<\/code> \u0438 <code>trun<\/code> \u0433\u043e\u0432\u043e\u0440\u044f\u0442, \u043a\u0430\u043a\u0438\u0435 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043b\u044f \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442. \u0415\u0441\u043b\u0438 \u0443 \u043a\u0430\u0434\u0440\u043e\u0432 \u043d\u0435\u0442 \u0441\u0432\u043e\u0435\u0439 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u0444\u043b\u0430\u0433 0x100 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442), \u0431\u0435\u0440\u0451\u043c \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u0435 \u0438\u0437 <code>tfhd<\/code> \u0438\u043b\u0438 \u0438\u0437 <code>trex<\/code>.<\/p>\n<pre><code class=\"javascript\">function fragmentDuration(buf, moof, tracks) {  let duration = 0;  for (const traf of boxes(buf, moof.payload, moof.end).filter((b) =&gt; b.type === \"traf\")) {    const children = boxes(buf, traf.payload, traf.end);    const tfhd = children.find((b) =&gt; b.type === \"tfhd\");    const tfdt = children.find((b) =&gt; b.type === \"tfdt\");    if (!tfhd || !tfdt || tfhd.payload + 8 &gt; tfhd.end || tfdt.payload + 8 &gt; tfdt.end) continue;    const track = tracks.get(buf.readUInt32BE(tfhd.payload + 4));    if (!track) continue;    const flags = buf.readUInt32BE(tfhd.payload) &amp; 0xffffff;    let cursor = tfhd.payload + 8;    if (flags &amp; 1) cursor += 8; \/\/ base-data-offset    if (flags &amp; 2) cursor += 4; \/\/ sample-description-index    if (flags &amp; 8 &amp;&amp; cursor + 4 &gt; tfhd.end) continue;    const sampleDuration = flags &amp; 8 ? buf.readUInt32BE(cursor) : track.defaultDuration;    const version = buf[tfdt.payload];    if (version === 1 &amp;&amp; tfdt.payload + 12 &gt; tfdt.end) continue;    let ticks =      version === 1        ? Number(buf.readBigUInt64BE(tfdt.payload + 4))        : buf.readUInt32BE(tfdt.payload + 4);    let samples = 0;    for (const trun of children.filter((b) =&gt; b.type === \"trun\")) {      if (trun.payload + 8 &gt; trun.end) return null;      const runFlags = buf.readUInt32BE(trun.payload) &amp; 0xffffff;      const count = buf.readUInt32BE(trun.payload + 4);      if (count &gt; 1_000_000 || (!(runFlags &amp; 0x100) &amp;&amp; !sampleDuration)) return null;      let pos = trun.payload + 8;      if (runFlags &amp; 1) pos += 4; \/\/ data-offset      if (runFlags &amp; 4) pos += 4; \/\/ first-sample-flags      const fields = [0x100, 0x200, 0x400, 0x800].filter((f) =&gt; runFlags &amp; f).length;      if (pos + count * fields * 4 &gt; trun.end) return null;      if (!(runFlags &amp; 0x100)) ticks += count * sampleDuration;      for (let i = 0; i &lt; count; i++) {        if (runFlags &amp; 0x100) ticks += buf.readUInt32BE(pos);        pos += fields * 4;      }      samples += count;    }    if (samples &amp;&amp; Number.isSafeInteger(ticks)) {      duration = Math.max(duration, ticks \/ track.timescale);    }  }  return duration &gt; 0 ? duration : null;}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u043c\u0435\u0441\u0442\u0435:<\/p>\n<pre><code class=\"javascript\">const HEAD_BYTES = 256 * 1024;const TAIL_BYTES = 2 * 1024 * 1024;async function probeVideoDuration(url) {  if (!\/^https?:\\\/\\\/\/i.test(url)) return null;  const head = await fetchRange(url, `bytes=0-${HEAD_BYTES - 1}`);  if (head) {    const fromHead = parseMvhd(head);    if (fromHead &gt; 0) return fromHead;  }  const tail = await fetchRange(url, `bytes=-${TAIL_BYTES}`);  if (!tail) return null;  const fromTail = parseMvhd(tail);  if (fromTail &gt; 0) return fromTail;  if (!head) return null;  const tracks = fragmentTracks(head);  if (!tracks.size) return null;  const offset = lastFragmentOffset(tail);  if (offset === null) return null;  const fragment = await fetchRange(url, `bytes=${offset}-${offset + HEAD_BYTES - 1}`);  const moof = fragment &amp;&amp; boxes(fragment).find((b) =&gt; b.type === \"moof\");  return moof ? fragmentDuration(fragment, moof, tracks) : null;}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<h3>\u0427\u0435\u0433\u043e \u043f\u0430\u0440\u0441\u0435\u0440 \u043d\u0435 \u0443\u043c\u0435\u0435\u0442<\/h3>\n<p>\u0427\u0435\u0441\u0442\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u0434\u0435\u043d\u044c\u0433\u0438.<\/p>\n<p><strong>\u041d\u0435\u0442 <\/strong><code><strong>mfra<\/strong><\/code><strong>, \u043d\u0435\u0442 \u043e\u0442\u0432\u0435\u0442\u0430.<\/strong> \u041e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0444\u0430\u0439\u043b\u0430 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435. \u0415\u0441\u043b\u0438 \u0435\u0433\u043e \u043d\u0435\u0442, \u044f \u043d\u0435 \u0437\u043d\u0430\u044e, \u0433\u0434\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442, \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e <code>null<\/code>. \u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0432\u0437\u044f\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 <code>moof<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043f\u0430\u043b \u0432 \u0445\u0432\u043e\u0441\u0442\u043e\u0432\u044b\u0435 \u0434\u0432\u0430 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442\u0430. \u041d\u043e \u0435\u0441\u043b\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0439, \u0432 \u043e\u043a\u043d\u043e \u043f\u043e\u043f\u0430\u0434\u0451\u0442 \u043f\u0440\u0435\u0434\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439, \u0438 \u044f \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u044e \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0439. \u041d\u0435\u0434\u043e\u0431\u0440\u0430\u0442\u044c \u0441 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0445\u0443\u0436\u0435, \u0447\u0435\u043c \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0444\u0430\u0439\u043b.<\/p>\n<p><strong>\u041e\u0431\u0440\u0435\u0437\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u043e\u0436\u0435 <\/strong><code><strong>null<\/strong><\/code><strong>.<\/strong> \u041b\u044e\u0431\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0433\u0440\u0430\u043d\u0438\u0446, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0435 \u0441\u043e\u0448\u043b\u0430\u0441\u044c, \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0442\u043a\u0430\u0437\u043e\u043c, \u0430 \u043d\u0435 \u0434\u043e\u0433\u0430\u0434\u043a\u043e\u0439.<\/p>\n<p><strong>\u0422\u043e\u043b\u044c\u043a\u043e MP4 \u0438 MOV.<\/strong> WebM \u0438 MKV \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u0438\u043d\u0430\u0447\u0435, \u0442\u0430\u043c \u0441\u0432\u043e\u0439 \u043f\u0430\u0440\u0441\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0443 \u043c\u0435\u043d\u044f \u043d\u0435\u0442.<\/p>\n<p><strong>\u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0443 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u0435\u0440\u0438\u0442\u044c.<\/strong> \u0424\u0430\u0439\u043b, \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u043c\u0430\u043d\u0443\u0442\u044c \u0441\u0447\u0451\u0442\u0447\u0438\u043a, \u043e\u0431\u043c\u0430\u043d\u0435\u0442 \u0438 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434. \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0443\u0449\u0435\u0440\u0431 \u0442\u043e, \u0447\u0442\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0441\u0430\u043c \u0440\u0435\u0436\u0435\u0442 \u0440\u043e\u043b\u0438\u043a\u0438 \u0434\u043b\u0438\u043d\u043d\u0435\u0435 \u0441\u0432\u043e\u0435\u0433\u043e \u043b\u0438\u043c\u0438\u0442\u0430. \u0414\u043b\u044f \u0437\u0430\u0449\u0438\u0442\u044b \u043e\u0442 \u0446\u0435\u043b\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u043f\u043e\u0434\u0434\u0435\u043b\u043a\u0438 \u043d\u0443\u0436\u0435\u043d \u043f\u043e\u043b\u043d\u044b\u0439 \u0440\u0430\u0437\u0431\u043e\u0440 \u0444\u0430\u0439\u043b\u0430, \u0438 \u044d\u0442\u043e \u0443\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430 \u0434\u043b\u044f ffprobe.<\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043f\u0430\u0440\u0441\u0435\u0440 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>null<\/code>, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u0438\u0434\u0438\u0442 \u043f\u0440\u043e\u0441\u044c\u0431\u0443 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0440\u043e\u043b\u0438\u043a \u0432 MP4 \u0438\u043b\u0438 MOV, \u0430 \u0432 \u043b\u043e\u0433 \u043f\u0438\u0448\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441 \u043f\u0440\u0438\u0447\u0438\u043d\u043e\u0439 \u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u0438. \u0411\u0435\u0437 \u0430\u0434\u0440\u0435\u0441\u0430 \u0444\u0430\u0439\u043b\u0430 \u0438 \u0431\u0435\u0437 \u0442\u0435\u043a\u0441\u0442\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430: \u0432 \u043b\u043e\u0433\u0430\u0445 \u0438\u043c \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u0447\u0435\u0433\u043e.<\/p>\n<h3>\u0413\u0440\u0430\u0431\u043b\u0438<\/h3>\n<p><strong>\u041e\u0442\u043a\u0430\u0437 \u0434\u043e \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0431\u0430\u0437\u0443 \u043d\u0435\u0432\u0438\u0434\u0438\u043c.<\/strong> \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0441\u0442\u043e\u044f\u043b\u0430 \u0440\u0430\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u043e \u0437\u0430\u0434\u0430\u0447\u0435. \u041b\u043e\u0433\u0438\u0447\u043d\u043e: \u0437\u0430\u0447\u0435\u043c \u0437\u0430\u0432\u043e\u0434\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u0435\u0439\u0447\u0430\u0441 \u043e\u0442\u043a\u043b\u043e\u043d\u0438\u043c. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043e\u0442\u043a\u0430\u0437 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0422\u0435\u043f\u0435\u0440\u044c \u043a\u0430\u0436\u0434\u0430\u044f \u0442\u0430\u043a\u0430\u044f \u0432\u0435\u0442\u043a\u0430 \u043f\u0438\u0448\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 \u043b\u043e\u0433.<\/p>\n<p><strong>\u0421\u0435\u0440\u0432\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c Range.<\/strong> \u0422\u043e\u0433\u0434\u0430 \u0432\u043c\u0435\u0441\u0442\u043e \u043a\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u0434\u0451\u0442 \u0432\u0435\u0441\u044c \u0444\u0430\u0439\u043b \u0441 \u043a\u043e\u0434\u043e\u043c 200. \u041a\u043e\u0434 \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u0436\u0438\u0432\u0451\u0442, \u0444\u0430\u0439\u043b \u0443\u0436\u0435 \u0441\u043a\u0430\u0447\u0430\u043d, \u043d\u043e \u043f\u0430\u043c\u044f\u0442\u044c \u0438 \u0432\u0440\u0435\u043c\u044f \u0443\u0439\u0434\u0443\u0442. \u0421\u0442\u043e\u0438\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u0432\u0430\u0448\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 206.<\/p>\n<p><strong>\u0412\u0435\u0440\u0441\u0438\u0438 \u0431\u043e\u043a\u0441\u043e\u0432.<\/strong> \u0423 <code>mvhd<\/code>, <code>mdhd<\/code>, <code>tkhd<\/code>, <code>tfdt<\/code> \u0438 <code>tfra<\/code> \u0435\u0441\u0442\u044c \u0432\u0435\u0440\u0441\u0438\u044f 0 \u0441 32-\u0431\u0438\u0442\u043d\u044b\u043c\u0438 \u043f\u043e\u043b\u044f\u043c\u0438 \u0438 \u0432\u0435\u0440\u0441\u0438\u044f 1 \u0441 64-\u0431\u0438\u0442\u043d\u044b\u043c\u0438. \u0421\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043f\u043e\u043b\u0435\u0439 \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u0441\u0434\u0432\u0438\u0433\u0430\u044e\u0442\u0441\u044f. \u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u0430\u0440\u0441\u0435\u0440\u0430 \u044f \u044d\u0442\u043e \u0443\u0447\u0451\u043b \u0434\u043b\u044f <code>mvhd<\/code> \u0438 \u0440\u0430\u0434\u043e\u0432\u0430\u043b\u0441\u044f, \u043a\u0430\u043a\u043e\u0439 \u044f \u043c\u043e\u043b\u043e\u0434\u0435\u0446.<\/p>\n<p><strong>Number \u0438 64 \u0431\u0438\u0442\u0430.<\/strong> <code>readBigUInt64BE<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 BigInt, \u0430 \u0434\u0430\u043b\u044c\u0448\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043e\u0431\u044b\u0447\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e. \u0414\u043b\u044f \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0439 \u044d\u0442\u043e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e, \u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 <code>Number.isSafeInteger<\/code> \u0441\u0442\u043e\u0438\u0442 \u0442\u0440\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u0438 \u0441\u043d\u0438\u043c\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441.<\/p>\n<p><strong>\u0411\u043e\u043d\u0443\u0441, \u043d\u0435 \u043f\u0440\u043e MP4.<\/strong> \u041f\u043e\u043a\u0430 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u043b\u0441\u044f, \u043d\u0430\u0448\u0451\u043b \u0432\u0442\u043e\u0440\u0443\u044e \u043f\u0440\u0438\u0447\u0438\u043d\u0443, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0440\u043e\u043b\u0438\u043a\u0438 \u043c\u043e\u0433\u043b\u0438 \u043d\u0435 \u0434\u043e\u0445\u043e\u0434\u0438\u0442\u044c. \u0412 Next.js, \u0435\u0441\u043b\u0438 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0435\u0441\u0442\u044c proxy (\u0440\u0430\u043d\u044c\u0448\u0435 \u043e\u043d \u043d\u0430\u0437\u044b\u0432\u0430\u043b\u0441\u044f middleware), \u0442\u0435\u043b\u043e \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0431\u0443\u0444\u0435\u0440\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u0447\u0442\u043e\u0431\u044b \u0435\u0433\u043e \u043c\u043e\u0433\u043b\u0438 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0438 proxy, \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a. \u0411\u0443\u0444\u0435\u0440 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d \u0434\u0435\u0441\u044f\u0442\u044c\u044e \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442\u0430\u043c\u0438. \u0412\u0441\u0451, \u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0435, \u0432 \u043d\u0435\u0433\u043e \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442. \u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0444\u0430\u0439\u043b\u043e\u0432 \u0448\u043b\u0430 \u0447\u0435\u0440\u0435\u0437 \u0442\u043e\u0442 \u0436\u0435 proxy, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u0435\u0441\u0441\u0438\u0438. \u042f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u043b \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438\u0437 proxy, \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0432\u0445\u043e\u0434\u0430 \u0442\u0430\u043c \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u044f. \u0410\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430: \u043f\u043e\u0434\u043d\u044f\u0442\u044c \u043b\u0438\u043c\u0438\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u043e\u0439 <code>proxyClientMaxBodySize<\/code>, \u043d\u043e \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u0442\u043e \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0440\u0430\u0434\u0438 \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043c\u043d\u0435 \u043d\u0435 \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c.<\/p>\n<h3>\u0418\u0442\u043e\u0433<\/h3>\n<p>\u0414\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c MP4 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043b\u0435\u0436\u0438\u0442 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435. \u0423 \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u043e\u043d\u0430 \u0432 <code>mvhd<\/code>, \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0438\u043b\u0438 \u0432 \u043a\u043e\u043d\u0446\u0435. \u0423 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u043c \u043d\u043e\u043b\u044c, \u0438 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0443\u044e \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0434\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0438\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435 <code>mfra<\/code>.<\/p>\n<p>\u041d\u0430 \u0432\u0441\u0451 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u0442\u0440\u0451\u0445 range-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u0434\u0432\u0443\u0445 \u0441 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u043e\u0439 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442 \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0440\u043e\u043b\u0438\u043a\u0430. \u041a\u043e\u0434 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u043a\u043e\u043b\u043e \u0434\u0432\u0443\u0445\u0441\u043e\u0442 \u0441\u0442\u0440\u043e\u043a \u0431\u0435\u0437 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0431\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u043b \u0437\u0430\u043d\u043e\u0432\u043e, \u044f \u0431\u044b \u0441\u0440\u0430\u0437\u0443 \u0432\u0437\u044f\u043b \u0444\u0430\u0439\u043b, \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043e\u043c \u0438\u043b\u0438 \u044d\u043a\u0440\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u044c\u044e, \u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u043e\u043b\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0430\u043c \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u0438\u0437 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430. \u0412\u0441\u0435 \u043c\u043e\u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0431\u044b\u043b\u0438 \u00ab\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435\u00bb, \u0438 \u043e\u0448\u0438\u0431\u043a\u0430 \u0436\u0434\u0430\u043b\u0430 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0447\u0443\u0436\u043e\u0433\u043e.<\/p>\n<p>PS \u0421\u043f\u0430\u0441\u0438\u0431\u043e, \u0447\u0442\u043e \u0434\u043e\u0447\u0438\u0442\u0430\u043b\u0438! \u0420\u0430\u0441\u0441\u043a\u0430\u0436\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445, \u043a\u0430\u043a\u043e\u0439 \u0444\u0430\u0439\u043b \u0441\u043b\u043e\u043c\u0430\u043b \u0432\u0430\u0448 \u00ab\u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439\u00bb \u043f\u0430\u0440\u0441\u0435\u0440, \u043c\u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u0442\u0430\u043a \u043e\u0431\u0438\u0434\u043d\u043e. \u0411\u0435\u0440\u0435\u0433\u0438\u0442\u0435 \u0441\u0435\u0431\u044f \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0439\u0442\u0435 \u043d\u0430 \u0447\u0443\u0436\u0438\u0445 \u0444\u0430\u0439\u043b\u0430\u0445!<\/p>\n<\/div>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1091264\/\">https:\/\/habr.com\/ru\/articles\/1091264\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043b \u0440\u043e\u043b\u0438\u043a \u043d\u0430 37 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u043e\u0442\u0432\u0435\u0442: \u00ab\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u0438\u0434\u0435\u043e\u00bb. \u0420\u043e\u043b\u0438\u043a \u0431\u044b\u043b \u043e\u0431\u044b\u0447\u043d\u044b\u0439, \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u043b\u0441\u044f \u0432 \u043b\u044e\u0431\u043e\u043c \u043f\u043b\u0435\u0435\u0440\u0435, ffprobe \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u043b 18 \u0441\u0435\u043a\u0443\u043d\u0434. \u0412 \u043b\u043e\u0433\u0430\u0445 \u043e\u0448\u0438\u0431\u043e\u043a \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435 \u0431\u044b\u043b\u043e \u0432\u043e\u043e\u0431\u0449\u0435. \u041f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c \u0440\u0430\u0437\u0431\u043e\u0440 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432 MP4, \u043f\u043e\u0447\u0435\u043c\u0443 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435 \u0444\u0430\u0439\u043b\u0430 \u043e\u043d\u0430 \u0431\u044b\u0432\u0430\u0435\u0442 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0438 \u043a\u0430\u043a \u0434\u043e\u0441\u0442\u0430\u0442\u044c \u0435\u0451 \u0442\u0440\u0435\u043c\u044f HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u0431\u0435\u0437 ffmpeg.\u0417\u0430\u0447\u0435\u043c \u043c\u0435\u0440\u0438\u0442\u044c \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435\u042f \u0434\u0435\u043b\u0430\u044e Aigena, \u0441\u0435\u0440\u0432\u0438\u0441, \u0433\u0434\u0435 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442 \u0438 \u043f\u0440\u0430\u0432\u044f\u0442 \u0432\u0438\u0434\u0435\u043e. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0442\u0430\u043c \u0441\u0442\u043e\u0438\u0442 \u0434\u0435\u043d\u0435\u0433 \u0437\u0430 \u043a\u0430\u0436\u0434\u0443\u044e \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u0440\u043e\u043b\u0438\u043a\u0430. \u0414\u043e\u043b\u0433\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u043b \u0431\u0440\u0430\u0443\u0437\u0435\u0440: \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043b \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u0430, \u043f\u043e\u043b\u043e\u0436\u0438\u043b \u0447\u0438\u0441\u043b\u043e \u0432 \u0437\u0430\u043f\u0440\u043e\u0441. \u0421\u0435\u0440\u0432\u0435\u0440 \u044d\u0442\u043e\u043c\u0443 \u0447\u0438\u0441\u043b\u0443 \u0432\u0435\u0440\u0438\u043b.\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u0430 \u0437\u0430\u0434\u043d\u0438\u043c \u0447\u0438\u0441\u043b\u043e\u043c. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443 \u0440\u043e\u043b\u0438\u043a \u0443\u0445\u043e\u0434\u0438\u0442 \u0446\u0435\u043b\u0438\u043a\u043e\u043c, \u0430 \u0441\u0447\u0451\u0442 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u0447\u0438\u0441\u043b\u0443 \u0438\u0437 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u041e\u0442\u043f\u0440\u0430\u0432\u0438\u043b duration: 1 \u0434\u043b\u044f \u043f\u044f\u0442\u0438\u043c\u0438\u043d\u0443\u0442\u043d\u043e\u0433\u043e \u0432\u0438\u0434\u0435\u043e, \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u043f\u044f\u0442\u044c \u043c\u0438\u043d\u0443\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u043e \u0446\u0435\u043d\u0435 \u043e\u0434\u043d\u043e\u0439 \u0441\u0435\u043a\u0443\u043d\u0434\u044b. \u041f\u043b\u0430\u0442\u0438\u043b \u0431\u044b \u0437\u0430 \u044d\u0442\u043e \u044f.\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0434\u043e \u043c\u0435\u0440\u0438\u0442\u044c \u0441\u0430\u043c\u043e\u043c\u0443, \u043f\u043e \u0444\u0430\u0439\u043b\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0436\u0435 \u043b\u0435\u0436\u0438\u0442 \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435.\u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0432 \u0433\u043e\u043b\u043e\u0432\u0443: ffprobe. \u041e\u043d \u0443\u043c\u0435\u0435\u0442 \u0447\u0438\u0442\u0430\u0442\u044c \u043f\u043e HTTP \u0438 \u0441\u0430\u043c \u0434\u0435\u043b\u0430\u0435\u0442 range-\u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442. \u042f \u0435\u0433\u043e \u043d\u0435 \u0432\u0437\u044f\u043b \u043f\u043e \u0434\u0432\u0443\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c. \u041d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u0441\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0434\u0435\u043d\u0435\u0433. \u0418 \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0442\u0430\u0449\u0438\u0442\u044c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a \u0440\u0430\u0434\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u0435, \u043a\u0430\u043a \u043c\u043d\u0435 \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u043b\u0435\u0436\u0438\u0442 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435 \u0444\u0430\u0439\u043b\u0430 \u043d\u0430 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435.\u041f\u0440\u043e \u00ab\u043d\u0430 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435\u00bb \u044f \u043e\u0448\u0438\u0431\u0430\u043b\u0441\u044f, \u043d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u043d\u0438\u0436\u0435.MP4 \u0437\u0430 \u0434\u0432\u0435 \u043c\u0438\u043d\u0443\u0442\u044b\u0424\u0430\u0439\u043b MP4 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0431\u043e\u043a\u0441\u043e\u0432. \u0423 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0431\u043e\u043a\u0441\u0430 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0447\u0435\u0442\u044b\u0440\u0435 \u0431\u0430\u0439\u0442\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0438 \u0447\u0435\u0442\u044b\u0440\u0435 \u0431\u0430\u0439\u0442\u0430 \u0438\u043c\u0435\u043d\u0438: ftyp, moov, mdat \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u0411\u043e\u043a\u0441\u044b \u0432\u043b\u043e\u0436\u0435\u043d\u044b \u0434\u0440\u0443\u0433 \u0432 \u0434\u0440\u0443\u0433\u0430, \u043a\u0430\u043a \u043f\u0430\u043f\u043a\u0438.\u0412\u0441\u0451, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043e \u0440\u043e\u043b\u0438\u043a\u0435, \u043b\u0435\u0436\u0438\u0442 \u0432 moov. \u0412\u043d\u0443\u0442\u0440\u0438 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c mvhd, \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0444\u0438\u043b\u044c\u043c\u0430, \u0430 \u0432 \u043d\u0451\u043c \u0434\u0432\u0430 \u043f\u043e\u043b\u044f: timescale, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0438\u043a\u043e\u0432 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0435, \u0438 duration, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0438\u043a\u043e\u0432 \u0434\u043b\u0438\u0442\u0441\u044f \u0440\u043e\u043b\u0438\u043a. \u0414\u0435\u043b\u0438\u043c \u043e\u0434\u043d\u043e \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0435 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0435\u043a\u0443\u043d\u0434\u044b.\u0422\u043e\u043d\u043a\u043e\u0441\u0442\u044c \u043e\u0434\u043d\u0430: moov \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u043e\u044f\u0442\u044c \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0444\u0430\u0439\u043b\u0430 \u0438\u043b\u0438 \u0432 \u043a\u043e\u043d\u0446\u0435. \u0415\u0441\u043b\u0438 \u0440\u043e\u043b\u0438\u043a \u0433\u043e\u0442\u043e\u0432\u0438\u043b\u0438 \u0434\u043b\u044f \u0432\u0435\u0431\u0430, \u0442\u043e \u0432 \u043d\u0430\u0447\u0430\u043b\u0435. \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0438\u0437 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430, \u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u0432\u0441\u0435\u0445 \u043c\u0435\u0434\u0438\u0430\u0434\u0430\u043d\u043d\u044b\u0445, \u0432 \u0445\u0432\u043e\u0441\u0442\u0435.\u041e\u0442\u0441\u044e\u0434\u0430 \u043f\u0435\u0440\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f. \u041f\u0440\u043e\u0441\u0438\u043c \u0443 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u043f\u0435\u0440\u0432\u044b\u0435 256 \u043a\u0438\u043b\u043e\u0431\u0430\u0439\u0442. \u041d\u0435 \u043d\u0430\u0448\u043b\u0438 mvhd, \u043f\u0440\u043e\u0441\u0438\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0434\u0432\u0430 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442\u0430.async function fetchRange(url, range) {  try {    const res = await fetch(url, {      headers: { Range: range },      signal: AbortSignal.timeout(15_000),    });    if (!res.ok) return null;    return Buffer.from(await res.arrayBuffer());  } catch {    return null;  }}\/\/ mvhd: version(1) flags(3) created modified timescale(4) duration\/\/ \u0412 \u0432\u0435\u0440\u0441\u0438\u0438 0 \u0434\u0430\u0442\u044b \u0438 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u043e 4 \u0431\u0430\u0439\u0442\u0430, \u0432 \u0432\u0435\u0440\u0441\u0438\u0438 1 \u043f\u043e 8.function parseMvhd(buf) {  const idx = buf.indexOf(&#171;mvhd&#187;, 0, &#171;latin1&#187;);  if (idx &lt; 0) return null;  const p = idx + 4;  if (buf[p] === 1) {    if (p + 32 &gt; buf.length) return null;    const timescale = buf.readUInt32BE(p + 20);    const duration = Number(buf.readBigUInt64BE(p + 24));    return timescale &gt; 0 ? duration \/ timescale : null;  }  if (p + 20 &gt; buf.length) return null;  const timescale = buf.readUInt32BE(p + 12);  const duration = buf.readUInt32BE(p + 16);  return timescale &gt; 0 ? duration \/ timescale : null;}\u0422\u0440\u0438\u0434\u0446\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 \u0432\u0441\u0451\u043c, \u0447\u0442\u043e \u044f \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u043b \u0441\u0430\u043c. \u0412\u044b\u043a\u0430\u0442\u0438\u043b \u0438 \u0437\u0430\u0431\u044b\u043b.\u0427\u0442\u043e \u0441\u043b\u043e\u043c\u0430\u043b\u043e\u0441\u044c\u0422\u0440\u0435\u0442\u044c\u0435\u0433\u043e \u043e\u043a\u0442\u044f\u0431\u0440\u044f \u043f\u0440\u0438\u0448\u0451\u043b \u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 \u0440\u043e\u043b\u0438\u043a \u043d\u0430 37 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442. \u0421\u0435\u0440\u0432\u0435\u0440 \u043e\u0442\u0432\u0435\u0442\u0438\u043b \u043e\u0442\u043a\u0430\u0437\u043e\u043c \u0435\u0449\u0451 \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u043b \u0437\u0430\u043f\u0438\u0441\u044c \u043e \u0437\u0430\u0434\u0430\u0447\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u043e\u0448\u0438\u0431\u043e\u043a \u0435\u0433\u043e \u043d\u0435 \u0431\u044b\u043b\u043e. \u0427\u0435\u043b\u043e\u0432\u0435\u043a \u0432\u0438\u0434\u0435\u043b \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435, \u044f \u043d\u0435 \u0432\u0438\u0434\u0435\u043b \u043d\u0438\u0447\u0435\u0433\u043e.\u042f \u0441\u043a\u0430\u0447\u0430\u043b \u0444\u0430\u0439\u043b \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u043b, \u0447\u0442\u043e \u0432 \u043d\u0451\u043c. mvhd \u043d\u0430 \u043c\u0435\u0441\u0442\u0435, \u0432 \u043f\u0435\u0440\u0432\u044b\u0445 \u043a\u0438\u043b\u043e\u0431\u0430\u0439\u0442\u0430\u0445. timescale \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439. duration \u0440\u0430\u0432\u0435\u043d \u043d\u0443\u043b\u044e.\u041d\u0435 \u043c\u0443\u0441\u043e\u0440, \u043d\u0435 \u043e\u0431\u0440\u0435\u0437\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b. \u0427\u0435\u0441\u0442\u043d\u044b\u0439 \u043d\u043e\u043b\u044c, \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u043c, \u043a\u0442\u043e \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0441\u043e\u0437\u0434\u0430\u043b.\u042d\u0442\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 MP4. \u0412 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u0432\u0441\u0435 \u043a\u0430\u0434\u0440\u044b, \u0430 \u0432 \u043a\u043e\u043d\u0446\u0435, \u043a\u043e\u0433\u0434\u0430 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0443\u0436\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430, \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438. \u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u0438\u0448\u0435\u0442\u0441\u044f \u043f\u043e-\u0434\u0440\u0443\u0433\u043e\u043c\u0443: \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0441\u0440\u0430\u0437\u0443, \u0430 \u043f\u043e\u0442\u043e\u043c \u043a\u0443\u0441\u043a\u0438 \u043f\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u043a\u0443\u043d\u0434, \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u043e \u0441\u0432\u043e\u0438\u043c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u043c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u043c moof. \u0422\u0430\u043a \u0443\u0434\u043e\u0431\u043d\u043e \u0441\u0442\u0440\u0438\u043c\u0438\u0442\u044c \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u043b\u0435\u0442\u0443: \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u043e\u0431\u043e\u0440\u0432\u0451\u0442\u0441\u044f, \u0443\u0436\u0435 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u043a\u0443\u0441\u043a\u0438 \u043e\u0441\u0442\u0430\u043d\u0443\u0442\u0441\u044f \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u043c\u0438.\u0426\u0435\u043d\u0430 \u044d\u0442\u043e\u0433\u043e \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u0437\u0430\u043f\u0438\u0441\u0438 \u0433\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0435\u0449\u0451 \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430. \u0418 \u0442\u0443\u0434\u0430 \u043f\u0438\u0448\u0443\u0442 \u043d\u043e\u043b\u044c.\u0412\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:ffmpeg -i input.mp4 -c copy -movflags frag_keyframe+empty_moov frag.mp4\u042f \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u0440\u043e\u043b\u0438\u043a\u0435 \u0432 18 \u0441\u0435\u043a\u0443\u043d\u0434. \u0412 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0431\u043e\u043a\u0441\u044b \u0438\u0434\u0443\u0442 \u0442\u0430\u043a: ftyp, free, mdat, moov, \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432 mvhd \u0440\u0430\u0432\u043d\u0430 18000. \u0412\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c: ftyp, moov, \u043f\u043e\u0442\u043e\u043c \u043f\u0430\u0440\u044b moof \u0438 mdat, \u0432 \u0441\u0430\u043c\u043e\u043c \u043a\u043e\u043d\u0446\u0435 mfra. \u0414\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432 mvhd \u0440\u0430\u0432\u043d\u0430 \u043d\u0443\u043b\u044e. ffprobe \u043d\u0430 \u043e\u0431\u043e\u0438\u0445 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 18 \u0441\u0435\u043a\u0443\u043d\u0434, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d \u0447\u0438\u0442\u0430\u0435\u0442 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b, \u0430 \u043d\u0435 \u0432\u0435\u0440\u0438\u0442 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0443.\u0413\u0434\u0435 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043b\u0435\u0436\u0438\u0442 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435\u0420\u0430\u0437 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u043c\u043e\u043b\u0447\u0438\u0442, \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0434\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0438\u0437 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043e\u0432. \u0427\u0438\u0442\u0430\u0442\u044c \u0432\u0441\u0435 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u043f\u043e\u0434\u0440\u044f\u0434 \u0437\u043d\u0430\u0447\u0438\u0442 \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0432\u0435\u0441\u044c \u0444\u0430\u0439\u043b, \u0430 \u044d\u0442\u043e\u0433\u043e \u044f \u0438 \u0445\u043e\u0442\u0435\u043b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c. \u041d\u0443\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439: \u0432\u0440\u0435\u043c\u044f \u0435\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043b\u044e\u0441 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0435\u0433\u043e \u043a\u0430\u0434\u0440\u043e\u0432 \u0438 \u0435\u0441\u0442\u044c \u043a\u043e\u043d\u0435\u0446 \u0440\u043e\u043b\u0438\u043a\u0430.\u041d\u0430\u0439\u0442\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0431\u043e\u043a\u0441 mfra \u0432 \u0445\u0432\u043e\u0441\u0442\u0435 \u0444\u0430\u0439\u043b\u0430. \u042d\u0442\u043e \u043e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435: \u0432 \u043d\u0451\u043c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0434\u043e\u0440\u043e\u0436\u043a\u0438 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043e, \u0441 \u043a\u0430\u043a\u043e\u0433\u043e \u0431\u0430\u0439\u0442\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442.\u0414\u0430\u043b\u044c\u0448\u0435 \u043f\u043e \u0446\u0435\u043f\u043e\u0447\u043a\u0435:\u0418\u0437 moov \u0431\u0435\u0440\u0451\u043c timescale \u043a\u0430\u0436\u0434\u043e\u0439 \u0434\u043e\u0440\u043e\u0436\u043a\u0438 (\u0431\u043e\u043a\u0441 mdhd) \u0438 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a\u0430\u0434\u0440\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e (\u0431\u043e\u043a\u0441 trex).\u0418\u0437 mfra \u0431\u0435\u0440\u0451\u043c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430.\u0422\u0440\u0435\u0442\u044c\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u0447\u0438\u0442\u0430\u0435\u043c 256 \u043a\u0438\u043b\u043e\u0431\u0430\u0439\u0442 \u0441 \u044d\u0442\u043e\u0433\u043e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f. \u0421\u0430\u043c moof \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439, \u043a\u0430\u0434\u0440\u044b \u0438\u0437 mdat \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u044b.\u0412 moof \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0434\u043e\u0440\u043e\u0436\u043a\u0438 \u0435\u0441\u0442\u044c tfdt, \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430, \u0438 trun, \u0441\u043f\u0438\u0441\u043e\u043a \u043a\u0430\u0434\u0440\u043e\u0432. \u0421\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043a\u0430\u0434\u0440\u043e\u0432.\u0414\u0435\u043b\u0438\u043c \u043d\u0430 timescale. \u0411\u0435\u0440\u0451\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u043f\u043e \u0434\u043e\u0440\u043e\u0436\u043a\u0430\u043c.\u041d\u0430 \u0442\u043e\u043c \u0440\u043e\u043b\u0438\u043a\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0442\u0430\u043a: \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430 536536, \u0432 \u043d\u0451\u043c \u0447\u0435\u0442\u044b\u0440\u0435 \u043a\u0430\u0434\u0440\u0430 \u043f\u043e 1001 \u0442\u0438\u043a\u0443, \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0435 30000 \u0442\u0438\u043a\u043e\u0432. (536536 + 4 \u00d7 1001) \/ 30000 = 18,018 \u0441\u0435\u043a\u0443\u043d\u0434\u044b.\u0422\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430: 256 \u041a\u0411, 2 \u041c\u0411 \u0438 \u0435\u0449\u0451 256 \u041a\u0411. \u041e\u043a\u043e\u043b\u043e \u0434\u0432\u0443\u0445 \u0441 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u043e\u0439 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442 \u0438\u0437 \u0442\u0440\u0438\u0434\u0446\u0430\u0442\u0438 \u0441\u0435\u043c\u0438.\u041a\u043e\u0434\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0431\u0449\u0438\u0439 \u0440\u0430\u0437\u0431\u043e\u0440 \u0431\u043e\u043a\u0441\u043e\u0432. \u0420\u0430\u0437\u043c\u0435\u0440 1 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u043b\u0435\u0436\u0438\u0442 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0432\u043e\u0441\u044c\u043c\u0438 \u0431\u0430\u0439\u0442\u0430\u0445, \u0440\u0430\u0437\u043c\u0435\u0440 0 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u00ab\u0434\u043e \u043a\u043e\u043d\u0446\u0430 \u0444\u0430\u0439\u043b\u0430\u00bb.function boxes(buf, start = 0, end = buf.length) {  const result = [];  for (let p = start; p + 8 &lt;= end; ) {    let size = buf.readUInt32BE(p);    let header = 8;    if (size === 1) {      if (p + 16 &gt; end) break;      size = Number(buf.readBigUInt64BE(p + 8));      header = 16;    } else if (size === 0) size = end &#8212; p;    if (!Number.isSafeInteger(size) || size &lt; header || p + size &gt; end) break;    result.push({      type: buf.toString(&#171;latin1&#187;, p + 4, p + 8),      start: p,      payload: p + header,      end: p + size,    });    p += size;  }  return result;}\u0414\u043e\u0440\u043e\u0436\u043a\u0438: \u043d\u043e\u043c\u0435\u0440 \u0438\u0437 tkhd, timescale \u0438\u0437 mdhd, \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a\u0430\u0434\u0440\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438\u0437 trex.function fragmentTracks(head) {  const tracks = new Map();  const moov = boxes(head).find((b) =&gt; b.type === &#171;moov&#187;);  if (!moov) return tracks;  const children = boxes(head, moov.payload, moov.end);  for (const trak of children.filter((b) =&gt; b.type === &#171;trak&#187;)) {    const inner = boxes(head, trak.payload, trak.end);    const tkhd = inner.find((b) =&gt; b.type === &#171;tkhd&#187;);    const mdia = inner.find((b) =&gt; b.type === &#171;mdia&#187;);    const mdhd = mdia &amp;&amp; boxes(head, mdia.payload, mdia.end).find((b) =&gt; b.type === &#171;mdhd&#187;);    if (!tkhd || !mdhd) continue;    \/\/ \u0412 \u0432\u0435\u0440\u0441\u0438\u0438 1 \u0434\u0430\u0442\u044b \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442 \u043f\u043e 8 \u0431\u0430\u0439\u0442, \u043f\u043e\u043b\u044f \u0441\u0434\u0432\u0438\u0433\u0430\u044e\u0442\u0441\u044f.    const idAt = tkhd.payload + (head[tkhd.payload] === 1 ? 20 : 12);    const scaleAt = mdhd.payload + (head[mdhd.payload] === 1 ? 20 : 12);    if (idAt + 4 &gt; tkhd.end || scaleAt + 4 &gt; mdhd.end) continue;    const timescale = head.readUInt32BE(scaleAt);    if (timescale) tracks.set(head.readUInt32BE(idAt), { timescale, defaultDuration: 0 });  }  const mvex = children.find((b) =&gt; b.type === &#171;mvex&#187;);  if (mvex) {    for (const trex of boxes(head, mvex.payload, mvex.end).filter((b) =&gt; b.type === &#171;trex&#187;)) {      if (trex.payload + 16 &gt; trex.end) continue;      const track = tracks.get(head.readUInt32BE(trex.payload + 4));      if (track) track.defaultDuration = head.readUInt32BE(trex.payload + 12);    }  }  return tracks;}\u0421\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430 \u0438\u0437 mfra. \u0417\u0430\u043f\u0438\u0441\u0438 \u0432 tfra \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b: \u0442\u0440\u0438 \u0434\u0432\u0443\u0445\u0431\u0438\u0442\u043d\u044b\u0445 \u043f\u043e\u043b\u044f \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435 \u0433\u043e\u0432\u043e\u0440\u044f\u0442, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0430\u0439\u0442 \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442 \u043d\u043e\u043c\u0435\u0440\u0430, \u043f\u043b\u044e\u0441 \u0432\u0440\u0435\u043c\u044f \u0438 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043f\u043e 4 \u0438\u043b\u0438 8 \u0431\u0430\u0439\u0442.function tailBox(buf, type) {  for (let at = buf.lastIndexOf(type); at &gt;= 4; at = buf.lastIndexOf(type, at &#8212; 1)) {    const size = buf.readUInt32BE(at &#8212; 4);    if (size &gt;= 8 &amp;&amp; at &#8212; 4 + size &lt;= buf.length) {      return { type, start: at &#8212; 4, payload: at + 4, end: at &#8212; 4 + size };    }  }}function lastFragmentOffset(tail) {  const mfra = tailBox(tail, &#171;mfra&#187;);  if (!mfra) return null;  let last = -1;  for (const tfra of boxes(tail, mfra.payload, mfra.end).filter((b) =&gt; b.type === &#171;tfra&#187;)) {    const p = tfra.payload;    if (p + 16 &gt; tfra.end) continue;    const wide = tail[p] === 1;    const lengths = tail.readUInt32BE(p + 8);    const count = tail.readUInt32BE(p + 12);    const width =      (wide ? 16 : 8) + ((lengths &gt;&gt; 4) &amp; 3) + ((lengths &gt;&gt; 2) &amp; 3) + (lengths &amp; 3) + 3;    const end = p + 16 + count * width;    if (!count || end &gt; tfra.end) continue;    const offsetAt = end &#8212; width + (wide ? 8 : 4);    const offset = wide ? Number(tail.readBigUInt64BE(offsetAt)) : tail.readUInt32BE(offsetAt);    if (Number.isSafeInteger(offset)) last = Math.max(last, offset);  }  return last &gt;= 0 ? last : null;}\u0418 \u0441\u0430\u043c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442. \u0424\u043b\u0430\u0433\u0438 \u0432 tfhd \u0438 trun \u0433\u043e\u0432\u043e\u0440\u044f\u0442, \u043a\u0430\u043a\u0438\u0435 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043b\u044f \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442. \u0415\u0441\u043b\u0438 \u0443 \u043a\u0430\u0434\u0440\u043e\u0432 \u043d\u0435\u0442 \u0441\u0432\u043e\u0435\u0439 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u0444\u043b\u0430\u0433 0x100 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442), \u0431\u0435\u0440\u0451\u043c \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u0435 \u0438\u0437 tfhd \u0438\u043b\u0438 \u0438\u0437 trex.function fragmentDuration(buf, moof, tracks) {  let duration = 0;  for (const traf of boxes(buf, moof.payload, moof.end).filter((b) =&gt; b.type === &#171;traf&#187;)) {    const children = boxes(buf, traf.payload, traf.end);    const tfhd = children.find((b) =&gt; b.type === &#171;tfhd&#187;);    const tfdt = children.find((b) =&gt; b.type === &#171;tfdt&#187;);    if (!tfhd || !tfdt || tfhd.payload + 8 &gt; tfhd.end || tfdt.payload + 8 &gt; tfdt.end) continue;    const track = tracks.get(buf.readUInt32BE(tfhd.payload + 4));    if (!track) continue;    const flags = buf.readUInt32BE(tfhd.payload) &amp; 0xffffff;    let cursor = tfhd.payload + 8;    if (flags &amp; 1) cursor += 8; \/\/ base-data-offset    if (flags &amp; 2) cursor += 4; \/\/&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-497637","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/497637","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=497637"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/497637\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=497637"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=497637"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=497637"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}