SharpAV1 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SharpAV1 --version 0.1.0
                    
NuGet\Install-Package SharpAV1 -Version 0.1.0
                    
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="SharpAV1" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SharpAV1" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="SharpAV1" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SharpAV1 --version 0.1.0
                    
#r "nuget: SharpAV1, 0.1.0"
                    
#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.
#:package SharpAV1@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SharpAV1&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=SharpAV1&version=0.1.0
                    
Install as a Cake Tool

SharpMP4

Simple lightweight fragmented mp4 (fmp4) reader/writer. Supports H264/H265/H266/AV1 for video and AAC/Opus for audio. No platform dependencies, easily portable cross-platform. It was designed to be a stream-in and stream-out solution for recording streams from IP cameras into fragmented MP4.

Read MP4

To parse an existing mp4/mov/m4v file, first you have to get the stream:

using (Stream inputFileStream = new BufferedStream(new FileStream("frag_bunny.mp4", FileMode.Open, FileAccess.Read, FileShare.Read)))
{
    ...
}

Create a new Container and call Read to get the in-memory representation of all the boxes.

var mp4 = new Container();
mp4.Read(new IsoStream(inputFileStream));    ...

To process this in-memory representation and read the audio/video samples, create a new VideoReader:

VideoReader videoReader = new VideoReader();
videoReader.Parse(fmp4);

Now it is possible to get all the tracks from the video:

IEnumerable<ITrack> tracks = videoReader.GetTracks();

To read the first track samples, call:

uint trackID = tracks.First().TrackID;
MediaSample sample = videoReader.ReadSample(trackID);

Where trackID is the ID of the track you want to read.

Build MP4

To write MP4 into a file, you first have to create the file:

using (Stream output = new BufferedStream(new FileStream("bunny_out.mp4", FileMode.Create, FileAccess.Write, FileShare.Read)))
{
    ...
}

Next, create the builder depending upon the output format. Currently, there are two builders - FragmentedMp4Builder and Mp4Builder.

IMp4Builder outputBuilder = new Mp4Builder(new SingleStreamOutput(output));

Add the H264 video track to the builder instance:

var videoTrack = new H264Track();
outputBuilder.AddTrack(videoTrack);

Add the AAC audio track to the builder instance:

var audioTrack = new AACTrack(2, 44100, 16);
outputBuilder.AddTrack(audioTrack);

Pass the track samples to the builder as follows:

byte[] nalu = ...;
outputBuilder.ProcessTrackSample(videoTrack.TrackID, nalu);

...

byte[] aac = ...;
outputBuilder.ProcessTrackSample(audioTrack.TrackID, aac);

When done, call FinalizeMedia to create the video file:

outputBuilder.FinalizeMedia();

Extensibility

Logging

There is a Log class where you can supply your own delegates for all the actions like:

Log.SinkWarn = (message, exception) => 
{
    ...
};

You can also enable/disable different trace levels like:

Log.WarnEnabled = false;

Credits

Huge inspiration for this project was the mp4parser https://github.com/sannies/mp4parser, thank you very much!

Product Compatible and additional computed target framework versions.
.NET 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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on SharpAV1:

Package Downloads
SharpMP4

Simple lightweight mp4/m4v/mov reader/writer. Supports H264/H265/H266/AV1 for video and AAC/Opus for audio.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.1 130 8/31/2025
0.1.0 152 8/30/2025