bloomtom.DEnc 2.1.0

dotnet add package bloomtom.DEnc --version 2.1.0
NuGet\Install-Package bloomtom.DEnc -Version 2.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="bloomtom.DEnc" Version="2.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add bloomtom.DEnc --version 2.1.0
#r "nuget: bloomtom.DEnc, 2.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.
// Install bloomtom.DEnc as a Cake Addin
#addin nuget:?package=bloomtom.DEnc&version=2.1.0

// Install bloomtom.DEnc as a Cake Tool
#tool nuget:?package=bloomtom.DEnc&version=2.1.0

DEnc: MPEG DASH Media Encoder

Easy dotnet DASH.

This library acts as a simplification interface wrapping around ffmpeg and mp4box. Simply pass in a file and the desired qualities, and the complicated commands and output processing is handled for you. The result is a set of media files and an mpd file.

Nuget Packages

Package Name Target Framework Version
DEnc .NET Standard 2.0 NuGet

Usage

v1.0 API (legacy)

Usage is fairly straightforward. Create a new instance of DEnc.Encoder then call encoder.GenerateDash. This version has been deprecated. The rest of this readme refers to the 2.0 API.

v2.0 API

This API version provides much more extensibility and insight for the library user. Standard usage remains simple though. Create your encoder instance, then call encoder.ProbeFile to get some MediaMetadata for the content you're converting. This probe step was broken out so you can inspect the media metadata before deciding on the encoding approach to use. Then create an instance of DashConfig, and pass that along with your media metadata to encoder.GenerateDash.

Usage Example
string inputPath = "/home/bloomtom/videos/ubuntu.iso"; // Your input video file.

var probeData = encoder.ProbeFile(inputPath, out _);
var qualities = Quality.GenerateDefaultQualities(DefaultQuality.Medium, H264Preset.Medium);
var dashConfig = new DashConfig(inputPath, "/home/bloomtom/encoded/", qualities);

var dashResult = encoder.GenerateDash(dashConfig, probeData);
DashConfig

The bulk of parameters for GenerateDash are contained in the data POCO DashConfig. The constructor for this performs several pre-check functions. When creating an instance of DashConfig, an exception will be thrown if the input path doesn't exist, the output directory doesn't exist, you gave a null or empty qualities parameter, or the set of qualities is not distinct on the bitrate. It also performs the function of either generating an output filename, or ensuring the filename given doesn't contain any illegal characters. The OutputFileName property has a setter, but it's recommended that you don't use it unless illegal character stripping of the output filename is undesirable.

Progress

Progress is now reported as one double precision value as the other stages turned out to take negligible time in practice.

Exceptions
  • ProbeFile

    • Exception

      Thrown if ffprobe cannot be run, or it throws a hard error.

    • InvalidOperationException

      May be thrown during deserialization of the ffprobe output. Deserialization is provided by XmlSerializer.

  • DashConfig

    • FileNotFoundException

      The input path does not exist.

    • DirectoryNotFoundException

      The output directory does not exist.

    • ArgumentNullException

      The qualities parameter is null.

    • ArgumentOutOfRangeException

      The qualities parameter is an empty set.

    • ArgumentException

      The set of qualities contains two or more qualities with the same bitrate.

  • GenerateDash

    • ArgumentNullException

      The given probedInputData value is null.

    • OperationCanceledException

      The given cancel token is triggered and a token checkpoint is reached.

    • FFMpegFailedException

      The base class for complex exceptions. Thrown when the ffmpeg encode process failed. The exception value contains detailed information about the running state, including the parameters given to ffmpeg, and StringBuilder containing the running log received from ffmpeg while it was running. This log can often contain insight into why the file could not be encoded.

      • Mp4boxFailedException

        Derives from FFMpegFailedException. Thrown when the MP4Box fails, and contains both the parameters given to ffmpeg and MP4Box, as well as the complete log from both processes.

        • DashManifestNotCreatedException

          Derives from Mp4boxFailedException. Thrown when after all processing, the expected .mpd dash manifest doesn't exist on disk. This exception really shouldn't be thrown, and exists more as a guarantee that when GenerateDash returns a value, the mpd file really exists, for sure. This exception contains everything you'd expect in an Mp4boxFailedException, as well as the expected path for the mpd file.

FAQ

What do I give for ffmpegPath, ffprobePath and boxPath?

You'll need an ffmpeg, ffprobe and mp4box executable on the system you're running from. If you put these in your path variable then the defaults can be left.

You can get executables for your platform here:

What are stdoutLog and stderrLog?

These parameters are optional on construction of DEnc.Encoder and provide a log stream from ffmpeg and MP4Box. For the v1.0 API it was recommended that you provide an action for them. On the v2.0 API these logs are recorded internally, and exceptions from GenerateDash include them, which means you probably need to collect them all the time yourself unless you really want to.

What are qualities?

Qualities are sets of parameters which direct an ffmpeg output stream. You can have several qualities to support DASH adaptive streaming

When you call encoder.GenerateDash a collection of qualities is required. It's important that the collection you provide is distinct on the bitrate, because the bitrate is used in output filenames to ensure they have unique names. Also, it doesn't make much sense to make multiple files at the same bitrate for a DASH encode anyway.

I asked for quality x,y,z but instead I got x,y,q or even just x,q instead. What gives?

The qualities you give may not be what's actually output. The desired Qualities list is crushed against the input file. Quality crushing happens when you ask for output bitrates within 10% of or greater than input file bitrate (by default). All bitrates which meet this criteria are removed from the qualities list, and they're replaced by a single copy quality that will mirror the input media exactly, or at least as close as ffmpeg can get it to be. This feature is definitely recommended to save disk space and reduce encode time, but it is optional. Set your DashConfig instance's QualityCrushTolerance property to zero to disable crushing for an encode.

I have extra subtitle files. How do I get them into the output mpd?

This is supported natively. Simply put vtt files alongside the source file with the same name, and they will be picked up. You can have multiple vtt files by using the naming format file.X.vtt. where X is some string or language code.

For the input file "myvideo.mp4", the following table shows what will be picked up as an external subtitle file.

Filename Language Imported?
myvideo.mp4 No, this is the source.
myvideo.srt No, only vtt is supported.
myvideo.vtt unk Yes
myvideo.2.vtt unk Yes
myvideo.subtitleasdf.vtt unk Yes
myvideo.en.vtt eng Yes
myvideo.jpn.vtt jpn Yes
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on bloomtom.DEnc:

Package Downloads
Sclinker.Infrastructure

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.0 342 3/20/2023
2.0.1-rc 393 8/15/2020
2.0.0-rc 320 8/13/2020
1.4.2 1,040 2/2/2020
1.4.1 592 1/29/2020
1.4.0 565 12/11/2019
1.3.6 480 12/6/2019
1.3.5 505 9/29/2019
1.3.4 505 9/4/2019
1.3.3 543 4/11/2019
1.3.2 579 3/19/2019
1.3.1 543 3/13/2019
1.3.0 564 3/12/2019
1.2.2 586 3/11/2019
1.2.1 541 3/10/2019
1.2.0 556 3/5/2019
1.1.4 639 2/8/2019
1.1.3 625 2/8/2019
1.1.2 624 1/26/2019
1.1.1 636 1/26/2019
1.1.0 704 1/18/2019
1.0.0 719 1/3/2019
0.2.8 677 11/28/2018
0.2.7 669 11/26/2018
0.2.6 818 9/11/2018
0.2.5 734 9/10/2018
0.2.4 734 9/10/2018
0.2.3 759 9/6/2018
0.2.2 798 8/15/2018
0.2.1 771 8/8/2018
0.2.0 804 8/7/2018
0.1.7 785 7/29/2018
0.1.6 821 7/28/2018
0.1.5 787 7/27/2018