EggEncoder 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package EggEncoder --version 0.1.0
                    
NuGet\Install-Package EggEncoder -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="EggEncoder" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EggEncoder" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="EggEncoder" />
                    
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 EggEncoder --version 0.1.0
                    
#r "nuget: EggEncoder, 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 EggEncoder@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=EggEncoder&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=EggEncoder&version=0.1.0
                    
Install as a Cake Tool

πŸ₯š EggEncoder

Audio encoding/decoding toolkit for .NET β€” native MP3/FLAC codec bindings, managed AAC/WMA decode, waveform generation, and an ffmpeg wrapper fallback, all behind one IMediaEncoder interface.

Sponsored by eggspot.app

CI NuGet MIT License

πŸ“– Full documentation β†’

Overview

EggEncoder gives you a single IMediaEncoder abstraction for probing, converting, and cutting audio files, backed by two interchangeable implementations:

  • NativeEncoder β€” pure .NET codec implementations (AAC, FLAC, MP3, WAV, WMA) plus native P/Invoke bindings to libmp3lame and libFLAC. No external process, no ffmpeg install required, fastest option on Windows x64.
  • FfmpegEncoder β€” shells out to an ffmpeg/ffprobe binary you provide. Broader format support (including video container probing via MOV/MP4), useful when you need formats the native codecs don't cover.

Both implementations return the same ProbeResult shape (duration, sample rate, bit depth, bitrate, waveform peaks) so callers can switch between them via configuration without touching call sites.

Why EggEncoder?

  • 🎯 One interface, two engines β€” swap native ⇄ ffmpeg via a single config flag
  • πŸš€ Native codec bindings β€” direct P/Invoke to LAME (MP3) and libFLAC, no subprocess overhead
  • 🎼 Broad format coverage β€” AAC, FLAC, MP3, WAV, WMA decode/encode; MOV/MP4 metadata probing
  • πŸ“Š Built-in waveform generation β€” normalized peak windows for any decoded stream
  • βœ‚οΈ Sample-accurate cutting β€” trim audio files without a full decodeβ†’encode round trip through ffmpeg
  • πŸͺΆ Dependency-light β€” only Microsoft.Extensions.*.Abstractions and NLayer
  • πŸ“– MIT licensed β€” see THIRD-PARTY-NOTICES.md for the bundled native codec licenses (LGPL-2.1 LAME, BSD-style libFLAC)

Installation

dotnet add package EggEncoder

Native codec binaries (libmp3lame.dll, libFLAC.dll) ship inside the package for win-x64 and are copied to your output directory automatically.

Quick Start

using EggEncoder;

// Dependency injection (recommended)
builder.Services.AddEggEncoder(options =>
{
    options.UseNativeEncoder = true; // or false to use ffmpeg
    // options.FfmpegBinPath = @"C:\tools\ffmpeg"; // required when UseNativeEncoder = false
});
public class MediaService(IMediaEncoder mediaEncoder)
{
    public async Task<ProbeResult> Inspect(string filePath) =>
        await mediaEncoder.Probe(filePath);

    public Task Transcode(string sourcePath, string destPath) =>
        mediaEncoder.ConvertFile(sourcePath, destPath);

    public Task Trim(string sourcePath, string destPath, int startSeconds, int endSeconds) =>
        mediaEncoder.CutFile(sourcePath, destPath, startSeconds, endSeconds);
}

Without DI

using EggEncoder;
using Microsoft.Extensions.Logging.Abstractions;

IMediaEncoder encoder = new NativeEncoder(NullLogger<NativeEncoder>.Instance);
var probeResult = await encoder.Probe("track.flac");

Supported Formats

Format Native probe Native decode Native encode ffmpeg
WAV βœ… βœ… βœ… βœ…
FLAC βœ… βœ… βœ… βœ…
MP3 βœ… βœ… βœ… βœ…
AAC βœ… βœ… βœ… βœ…
WMA βœ… βœ… ❌ βœ…
MOV/MP4 (metadata only) βœ… ❌ ❌ βœ…

NativeEncoder.CutFile supports WAV, FLAC, MP3, and AAC (sample-accurate, no re-encode of the untouched region). FfmpegEncoder supports whatever your ffmpeg build supports.

Configuration

EggEncoderOptions:

Property Type Description
UseNativeEncoder bool true resolves IMediaEncoder as NativeEncoder; false resolves FfmpegEncoder. Default false.
FfmpegBinPath string? Directory containing ffmpeg.exe and ffprobe.exe. Required when UseNativeEncoder is false. FfmpegEncoderBinFactory throws FileNotFoundException at startup if either binary is missing β€” EggEncoder does not download or provision ffmpeg for you.

License

MIT β€” see LICENSE. EggEncoder bundles pre-built libmp3lame.dll (LGPL-2.1) and libFLAC.dll (BSD-style) as separate, dynamically-loaded native binaries; see THIRD-PARTY-NOTICES.md for details.

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 is compatible.  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 is compatible.  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.

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
4.3.0 0 8/12/2026
4.2.0 0 8/12/2026
4.1.0 84 8/6/2026
4.0.0 100 8/5/2026
3.0.0 103 8/5/2026
2.0.0 97 8/5/2026
1.0.0 105 8/4/2026
0.1.0 92 8/4/2026