SpawnDev.EBML
1.0.2
See the version list below for details.
dotnet add package SpawnDev.EBML --version 1.0.2
NuGet\Install-Package SpawnDev.EBML -Version 1.0.2
<PackageReference Include="SpawnDev.EBML" Version="1.0.2" />
paket add SpawnDev.EBML --version 1.0.2
#r "nuget: SpawnDev.EBML, 1.0.2"
// Install SpawnDev.EBML as a Cake Addin #addin nuget:?package=SpawnDev.EBML&version=1.0.2 // Install SpawnDev.EBML as a Cake Tool #tool nuget:?package=SpawnDev.EBML&version=1.0.2
SpawnDev.EBML
Name | Package | Description |
---|---|---|
SpawnDev.EBML | An extendable .Net library for reading and writing Extensible Binary Meta Language (aka EBML) documents. Includes schema for Matroska and WebM. |
The demo project, EBMLViewer, included in the project is a .Net 8 Forms app for testing the library and viewing EBML documents.
EBMLDocumentReader
EBMLDocumentReader is the base EBML document parser. The EBMLDocumentReader can be given a list of EBMLSchemas that tell it how to process EBML documents with a matching EBML.DocType value. WebM and Matroska EBMLSchemas are included in the library as WebMSchema and MatroskaSchema.
WebMDocumentReader
To fix the duration in a WebM file, WebM parser reads the Timecode information from Clusters and SimpleBlocks and adds a Segment > Info > Duration element with the new duration.
Example of how to add Duration info if not found in a the WebM stream.
using var inputStream = new FileStream(inputFile, FileMode.Open, FileAccess.Read, FileShare.Read);
var webm = new WebMDocumentReader(inputStream);
// FixDuration returns true if the WebM was modified
var modified = webm.FixDuration();
// webm.DataChanged will also be true if the WebM is modified
if (modified)
{
var outFile = Path.Combine(Path.GetDirectoryName(inputFile)!, Path.GetFileNameWithoutExtension(inputFile) + ".fixed" + Path.GetExtension(inputFile));
using var outputStream = new FileStream(outFile, FileMode.Create, FileAccess.Write, FileShare.None);
webm.CopyTo(outputStream);
}
Example of how to get an element
var durationElement = webm.GetElement<FloatElement>(MatroskaId.Segment, MatroskaId.Info, MatroskaId.Duration);
var duration = durationElement?.Data ?? 0;
Example of how to get all elements of a type
var segments = webm.GetElements<ContainerElement>(MatroskaId.Segment);
Example of how to use ElementIds to walk the data tree and access information
var segments = webm.GetContainers(MatroskaId.Segment);
foreach (var segment in segments)
{
var clusters = segment.GetContainers(MatroskaId.Cluster);
foreach (var cluster in clusters)
{
var timecode = cluster.GetElement<UintElement>(MatroskaId.Timecode);
if (timecode != null)
{
duration = timecode.Data;
};
var simpleBlocks = cluster.GetElements<SimpleBlockElement>(MatroskaId.SimpleBlock);
var simpleBlockLast = simpleBlocks.LastOrDefault();
if (simpleBlockLast != null)
{
duration += simpleBlockLast.Timecode;
}
}
}
Example of how to add an element
All parent containers are automatically marked Modified if any children are added, removed, or changed.
var info = GetContainer(MatroskaId.Segment, MatroskaId.Info);
info!.Add(MatroskaId.Duration, 100000);
EBMLViewer
EBMLViewer is a demo app for the library. Supports WebM, Matroska, or any other EBML documents.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- No dependencies.
-
net7.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.