SpawnDev.EBML 1.0.2

There is a newer version of this package available.
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                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SpawnDev.EBML" Version="1.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SpawnDev.EBML --version 1.0.2                
#r "nuget: SpawnDev.EBML, 1.0.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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 NuGet version 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.

alternate text is missing from this package README image

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.

Version Downloads Last updated
2.0.0 149 8/21/2024
1.0.4 119 8/11/2024
1.0.3 4,345 1/22/2024
1.0.2 103 1/18/2024
1.0.1 120 1/17/2024
1.0.0 115 1/16/2024