FFmpeg.Loader
2.0.0
See the version list below for details.
dotnet add package FFmpeg.Loader --version 2.0.0
NuGet\Install-Package FFmpeg.Loader -Version 2.0.0
<PackageReference Include="FFmpeg.Loader" Version="2.0.0" />
paket add FFmpeg.Loader --version 2.0.0
#r "nuget: FFmpeg.Loader, 2.0.0"
// Install FFmpeg.Loader as a Cake Addin #addin nuget:?package=FFmpeg.Loader&version=2.0.0 // Install FFmpeg.Loader as a Cake Tool #tool nuget:?package=FFmpeg.Loader&version=2.0.0
FFmpeg.Loader
Tooling to find and load FFmpeg libraries with the FFmpeg.AutoGen bindings.
This library was designed for use with FFmpeg.Native as a more flexible alternative to FFmpeg.Native's tooling for finding FFmpeg libs. However please note, FFmpeg.Native is unnecessary if FFmpeg libraries have been installed elsewhere (it's just a convenient method of packaging the binaries in your application): just point this project's FFmpegLoader at the appropriate directory if it can't find the binaries on its own.
Features
- Searches for appropriate FFmpeg libraries in a number of locations relative to the current executable.
- Can be configured to also first search a custom list of locations.
- Registers the located binaries for use with FFmpeg.AutoGen.
- Works around a restriction on some Windows systems which prevents a DLL library being loaded from a non-default location.
Usage
See the code samples below for basic usage of FFmpegLoader. If the libraries cannot be located, then a DllNotFoundException
is thrown.
The default paths that FFmpegLoader searches for FFmpeg libraries are the assembly's directory in your executing application, and several specific subdirectories relative to that dependent on the current OS and architecture. These default paths match the location that FFmpeg.Native installs to, e.g.:
- .
- .\runtimes\win7-x64\native{name}-{version}.dll
- ./runtimes/linux-x64/native/lib{name}.so.{version}
- etc.
using FFmpeg.Loader;
//Search a set of default paths for FFmpeg libraries, relative to the FFmpeg.Loader assembly and then set FFmpeg.AutoGen to load the first matching FFmpeg binaries.
FFmpegLoader.SearchDefaults().Load();
//Search a set of paths for FFmpeg libraries, and then set FFmpeg.AutoGen to load the first matching FFmpeg binaries.
FFmpegLoader.SearchPaths("/usr/lib/x86_64-linux-gnu", "/usr/bin/ffmpeg").Load();
//The following two examples are functionally identical and combines both of the approaches above.
//They first search a default set of paths relative to the FFmpeg.Loader assembly, and then search a list of manually specified paths.
//Finally they set FFmpeg.AutoGen to load the first matching FFmpeg binaries.
FFmpegLoader.SearchDefaults().ThenSearchPaths("/usr/lib/x86_64-linux-gnu", "/usr/bin/ffmpeg").Load();
FFmpegLoader.SearchDefaults().ThenSearchPaths("/usr/lib/x86_64-linux-gnu").ThenSearchPaths("/usr/bin/ffmpeg").Load();
//The following two examples are functionally identical and search the same paths as above, but search the manually specified paths first
//and then fall back on searching a set of default paths.
//As above, they finally set FFmpeg.AutoGen to load the first matching FFmpeg binaries.
FFmpegLoader.SearchPaths("/usr/lib/x86_64-linux-gnu", "/usr/bin/ffmpeg").ThenSearchDefaults().Load();
FFmpegLoader.SearchPaths("/usr/lib/x86_64-linux-gnu").ThenSearchPaths("/usr/bin/ffmpeg").ThenSearchDefaults().Load();
After defining the initial search paths, there are several more methods and overloads you may find useful:
//Returns an instance with additional search-locations. This method can be chained as many times as necessary.
//Additional locations are a predefined set of defaults relative to the specified rootDir parameter.
//If rootDir is null then the FFmpegLoader assembly folder is used for resolving relative paths.
FFmpegLoaderSearch ThenSearchDefaults(string rootDir = null);
//Returns an instance with additional search-locations. This method can be chained as many times as necessary.
//Values provided in searchPaths are expected to be either absolute or relative to the directory containing the FFmpegLoader assembly.
FFmpegLoaderSearch ThenSearchPaths(params string[] searchPaths);
//Locates a specific FFmpeg library with a specific version. Returns null if no matching library is found.
IFileInfo Find(string name, int version);
//Locates a specific FFmpeg library with a version number provided by FFmpeg.AutoGen. Returns null if no matching library is found.
IFileInfo Find(string name);
//Search the defined search-locations for an FFmpeg library with a specific name and version and set FFmpeg.AutoGen to load from there.
//Throws DllNotFoundException if no matching library is found.
string Load(string name, int version);
//Search the defined search-locations for an FFmpeg library with a specific name (version provided by FFmpeg.AutoGen) and set FFmpeg.AutoGen to load from there.
//Throws DllNotFoundException if no matching library is found.
string Load(string name = "avutil");
FFmpeg versions
This library searches for specific FFmpeg library versions. If your FFmpeg DLLs have different version numbers than expected, then they won't be found. The versions it looks for are pulled from the FFmpeg.AutoGen project's ffmpeg.LibraryVersionMap[]
dictionary.
At the time of writing this, FFmpeg.AutoGen 4.x currently specifies: Library |Version --- |--- avcodec |58 avdevice |58 avfilter |7 avformat |58 avutil |56 postproc |55 swresample|3 swscale |5
If any of your FFmpeg binaries are of a different version, you may need to explicitly install a newer/older version of FFmpeg.AutoGen into your project.
Attribution
This project contains some C# code based on, and modified, from the LGPL-3.0 licensed FFmpeg.Native project.
Product | Versions 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. |
-
.NETStandard 2.0
- FFmpeg.AutoGen (>= 4.4.1.1)
- System.Collections.Immutable (>= 6.0.0)
- System.IO.Abstractions (>= 17.0.21)
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 |
---|---|---|
3.0.2 | 3,046 | 8/10/2023 |
3.0.2-ci0007 | 110 | 8/10/2023 |
3.0.1 | 191 | 8/2/2023 |
3.0.1-ci0005 | 122 | 8/2/2023 |
3.0.1-ci0003 | 116 | 8/2/2023 |
3.0.0 | 13,589 | 7/25/2022 |
2.1.1 | 505 | 7/12/2022 |
2.1.0 | 450 | 7/12/2022 |
2.0.0 | 448 | 7/11/2022 |
1.0.1 | 782 | 5/7/2021 |
1.0.0 | 379 | 5/7/2021 |