SharpRTSPClient 0.3.0
dotnet add package SharpRTSPClient --version 0.3.0
NuGet\Install-Package SharpRTSPClient -Version 0.3.0
<PackageReference Include="SharpRTSPClient" Version="0.3.0" />
<PackageVersion Include="SharpRTSPClient" Version="0.3.0" />
<PackageReference Include="SharpRTSPClient" />
paket add SharpRTSPClient --version 0.3.0
#r "nuget: SharpRTSPClient, 0.3.0"
#:package SharpRTSPClient@0.3.0
#addin nuget:?package=SharpRTSPClient&version=0.3.0
#tool nuget:?package=SharpRTSPClient&version=0.3.0
SharpRTSP client and server
This is a thin wrapper around the fantastic SharpRTSP, mostly based off their sample code with some API enhancements to make it easier to use. Added support for streaming Opus, AV1 and H266.
SharpRTSPClient
Simple RTSP client that supports MJPEG, H264, H265, H266, AV1 for video and AAC, Opus, PCMU and PCMA for audio.
Create the RTSP client:
using (RTSPClient client = new RTSPClient())
{
...
}
Subscribe events for video:
client.NewVideoStream += (sender, e) => { ... }
client.ReceivedVideoData += (sender, e) => { ... }
The NewVideoStream callback will contain the video codec in e.StreamType as well as codec-specific info such as SPS/PPS from the SDP in e.StreamConfigurationData.
Subscribe events for audio:
client.NewAudioStream += (sender, e) => { ... }
client.ReceivedAudioData += (sender, e) => { ... }
The NewAudioStream callback will contain the audio codec in e.StreamType as well as codec-specific info from the SDP in e.StreamConfigurationData.
For re-connection, you can optionally subscribe the Stopped event:
client.Stopped += (sender, e) =>
{
client.TryReconnect();
}
Connect to the RTSP stream:
client.Connect("rtsp://localhost:8554/stream1", RTPTransport.TCP);
Now you will start receiving callbacks with audio/video payload.
To disconnect the RTSP stream, call Stop or just dispose the client:
client.Stop();
SharpRTSPServer
Simple RTSP server that supports MJPEG, H264, H265, H266, AV1 for video and AAC, Opus, PCMU and PCMA for audio.
Create the server on port 8554:
using(var server = new RTSPServer(8554, "admin", "password"))
{
...
}
Create tracks for the media you want to stream. For instance H264 video with AAC audio:
var h264Track = new H264Track();
h264Track.SetParameterSets(sps, pps); // Sequence Parameter Set (SPS) and Picture Parameter Set (PPS) are provided by your video source as byte[]
var aacTrack = new AACTrack(audioSpecificConfig, samplingRate, channelCount); // audioSpecificConfig is provided by your audio source as byte[], samplingRate and channelCount are also properties of the audio source
Create a stream source from the tracks an add it to the server:
var streamSource = new RTSPStreamSource("stream1", h264Track, aacTrack);
server.AddStreamSource(streamSource);
Multiple streams can be added, each identified by unique stream ID:
var streamSource2 = new RTSPStreamSource("stream2", h265Track, null);
server.AddStreamSource(streamSource2);
Start listening for incoming requests:
server.StartListen();
To stream video, use the track instances and call FeedInRawSamples in regular intervals:
h264Track.FeedInRawSamples(rtpVideoBaseTime + videoPTS, new List<byte[]> { nal1, nal2, ... });
The same applies to audio:
aacTrack.FeedInRawSamples(rtpAudioBaseTime + audioPTS, new List<byte[]> { aacFrame });
Samples
RTSP Server App
Simple RTSP server that supports streaming video from multiple MP4 files.
RTSP Recorder App
Demonstrates how to record RTSP and save it as mp4.
FFmpeg RTSP Server
Sample RTSP server for ffmpeg RTP streams. Fully configurable in appsettings.json.
PCAPNG RTSP Server
PoC of re-playing RTSP from a Wireshark PcapNg file.
Credits
Most of the work has been done by SharpRTSP (https://github.com/ngraziano/SharpRTSP), this is just a convenience wrapper around it.
| 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 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. |
| .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. |
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SharpRTSPClient:
| Package | Downloads |
|---|---|
|
SharpRTSPtoWebRTC
A C# implementation of the RTSP to WebRTC gateway that allows you to stream RTSP from various sources to the web browser. Suppports H264, H265 and AV1 re-streaming. Audio transcoding from AAC to Opus is also supported. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.3.0 | 109 | 11/1/2025 |
| 0.2.0 | 132 | 10/26/2025 |
| 0.1.4 | 529 | 8/30/2025 |
| 0.1.3 | 572 | 5/31/2025 |
| 0.1.2 | 322 | 5/15/2025 |
| 0.1.1 | 285 | 5/15/2025 |
| 0.1.0 | 733 | 4/5/2025 |
| 0.0.8 | 225 | 3/29/2025 |
| 0.0.7 | 199 | 3/20/2025 |
| 0.0.6 | 265 | 2/2/2025 |
| 0.0.5 | 538 | 11/10/2024 |
| 0.0.4 | 1,890 | 6/16/2024 |
| 0.0.3 | 176 | 6/15/2024 |
| 0.0.2 | 179 | 6/15/2024 |
| 0.0.1 | 189 | 6/15/2024 |