Cross-platform audio and video media end-points for the SIPSorcery real-time communications library, built on top of native FFmpeg libraries via FFmpeg.AutoGen.
Tested on Windows, macOS, and Linux.
Licence note. Unlike the rest of the SIPSorcery family this package is licensed under LGPL-2.1-only (because it links FFmpeg at runtime, and FFmpeg's default build is LGPL). Make sure that's acceptable for your application before depending on it.
dotnet add package SIPSorcery
dotnet add package SIPSorceryMedia.FFmpegYou also need the FFmpeg shared libraries installed on the target machine -- this NuGet package wraps FFmpeg, it doesn't ship the binaries. See Installing FFmpeg below.
- Video: VP8, H.264, H.265, MJPEG.
- Audio: PCMU (G.711), PCMA (G.711), G.722, G.729, Opus.
| Class | Source kind |
|---|---|
FFmpegFileSource |
Local files or remote URIs (HTTP, RTSP, ...) -- audio + video. |
FFmpegCameraSource |
Local webcam capture -- video. |
FFmpegScreenSource |
Screen / monitor capture -- video. |
FFmpegMicrophoneSource |
Microphone capture -- audio. |
You can mix any video source (or none) with any audio source (or none) when assembling a media session.
| Class | Purpose |
|---|---|
FFmpegVideoEncoder |
IVideoEncoder -- VP8 / H.264 / H.265 / MJPEG encode + decode. |
FFmpegAudioEncoder |
IAudioEncoder -- audio codec encode + decode for the codecs above. |
FFmpegVideoEndPoint |
Convenience pairing of source + encoder + sink. |
- No audio output. This package does not provide a speaker / playback end-point. For audio playback pair it with a platform end-point such as SIPSorceryMedia.Windows on Windows or SIPSorcery.SDL2 on other platforms.
The shared libraries this package binds to must be discoverable on the target machine's library load path. Typical setups:
The simplest path is winget:
winget install "FFmpeg (Shared)" --version 8.1That puts the DLLs somewhere SIPSorceryMedia.FFmpeg can find them.
Alternative -- download a "shared" build from
gyan.dev/ffmpeg/builds/#release-builds
or use the binaries shipped with
FFmpeg.AutoGen,
and add them to your PATH.
sudo apt install ffmpeg(Equivalent for dnf, pacman, etc. on other distributions.)
brew install ffmpeg
brew install mono-libgdiplus # for the test apps that draw bitmapsThis package targets the FFmpeg 8.1 ABI via FFmpeg.AutoGen 8.1.0. Older
or much newer FFmpeg installations may load with PInvoke errors. If
you see EntryPointNotFoundException or DllNotFoundException at
startup, the most common cause is an FFmpeg version mismatch.
The
WebRTCTestPatternServer
example shows the minimal end-to-end path: a video test-pattern source,
encoded with FFmpeg's H.264 encoder, sent over WebRTC to a browser.
Sketch:
using SIPSorcery.Media;
using SIPSorcery.Net;
using SIPSorceryMedia.FFmpeg;
FFmpegInit.Initialise(); // load the shared libs on whatever PATH is configured
var pc = new RTCPeerConnection(null);
var source = new VideoTestPatternSource(new FFmpegVideoEncoder());
var track = new MediaStreamTrack(source.GetVideoSourceFormats(), MediaStreamStatusEnum.SendOnly);
pc.addTrack(track);
source.OnVideoSourceEncodedSample += pc.SendVideo;
pc.OnVideoFormatsNegotiated += formats => source.SetVideoSourceFormat(formats.First());The repo includes a console test harness at
test/FFmpegFileAndDevicesTest
that exercises file, camera, and screen sources end-to-end.
- SIPSorcery -- the main real-time communications library.
- SIPSorceryMedia.Abstractions -- the interfaces this package implements.
- SIPSorceryMedia.Windows -- Windows-only audio + video device access (no FFmpeg dependency).
- SIPSorcery.VP8 -- pure C# VP8 codec (no native dependency).
LGPL-2.1-only. The rest of the SIPSorcery family is BSD-3-Clause; this package is the exception because of FFmpeg's licensing.