@ fix-webm- 期限/ parser
将 Webm 文件分解到单个区域,编辑区域, ,然后从编辑的章节中将文件编译回来.
警告:这是内部执行软件包,这里的接口随时可以改变! 请不要在生产代码中直接使用, 只用于在开发时调试 Webm 文件的内容 !
安装
从软件包管理器安装 :
npm install @fix-webm-duration/parser
使用量
分析一个小块:
import { WebmFile } from "@fix-webm-duration/parser";
const file = await WebmFile.fromBlob(blob);
它会回到一个实例 WebmFile,这是一棵带ID的树.
WebmFile 财务报告和审定财务报表 WebmContainer 是其他部分的容器,
和所有其他类 webm 节点(WebmUint, (中文(简体) ), WebmFloat, (中文(简体) ), WebmString)是树的最后叶.
WebmBase 是用于未识别ID的节点的基节点类
(库中webm节点的地图不全,仅是一组需要修补webm持续时间的节点.
轨迹节点 :
这个 data 解析的字段 WebmContainer (或 WebmFile对象
包含儿童节点列表(可以是叶片或其他部分).
使用 getSectionById 通过身份识别直接获得儿童部分的方法,例如.
const segmentSection: WebmContainer | null = file.getSectionById(0x8538067);
可在 段落.ts 文件。 。 。 .
修改节点
使用 setValue 用于修改节点值的方法,例如:.
const durationSection = infoSection.getSectionById(0x489);
if (!durationSection) throw new Error("Duration section not found");
durationSection.setValue(60000);
访问常规数组方法 data 字段可以添加或去除某个段落的子节点,例如.
const durationSection = new WebmFloat("Duration");
durationSection.setValue(duration);
infoSection.data!.push({
id: 0x489,
data: durationSection,
});
将修改后的文件编译回 blob
打电话 updateByData 所有修改的方法 WebmContainer 财务报告和审定财务报表 WebmFile 对象的倒序,
即从最有巢结的节点开始,以 WebmFile 对象.
打电话 toBlob 文件将解析后的文件转换为 blob 的方法.
如果不是默认的话, 将 MIME 类型传给它, 例如 . file.toBlob("audio/webm")。 。 。 .