RtspViewer 1.0.2

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

RtspViewer

RTSP 视频显示与录制 WinForms 控件。纯 FFmpeg 实现,零第三方托管/原生依赖,自带 ffmpeg.exe,装包即用。

  • 实时预览:ffmpeg 拉流解码,C# 侧零图像处理库
  • 高压缩录制:H.264(libx264, CRF 模式),同画质体积约为 MJPG 的 1/50
  • 录制分辨率缩放、帧率抽帧均由 ffmpeg 完成,不占 C# 侧 CPU
  • 断流自动重连,RTSP 支持 tcp/udp 传输切换

安装

dotnet add package RtspViewer

安装后构建,包内自带的 ffmpeg.exe 会自动复制到输出目录 ffmpeg\ffmpeg.exe,无需任何手动配置(间接引用你的库时同样生效)。

快速开始

using RtspViewer;

var video = new VideoDisplay
{
    Dock = DockStyle.Fill,
    VideoAddress = "rtsp://admin:123456@192.168.1.64:554/Streaming/Channels/101",
    RecordDirectory = "Recordings",   // 录像保存目录
    RecordScale = 0.5,                // 宽高减半,体积约为原始 1/4
    RecordCrf = 28,                   // 压缩质量,监控回查推荐 28
};
Controls.Add(video);   // AutoStart=true,句柄创建后自动连接

video.IsRecording = true;    // 开始录制
video.IsRecording = false;   // 停止并保存 mp4

常用属性

属性 默认 说明
VideoAddress - RTSP 流地址
AutoStart true 控件创建后自动连接
ReconnectInterval 1500 断流重连间隔(ms)
IsRecording false 置 true 开始录制,false 停止保存
RecordDirectory Recordings 录像保存目录
RecordFps 15 录制帧率(不要超过相机实际帧率)
RecordScale 0.5 录制分辨率缩放,1=原始,0.5=宽高减半
RecordCrf 28 压缩质量:18≈无损观感,23=标准,28=监控推荐,35=极限
RecordPreset veryfast 编码速度:veryfast 省 CPU,slow 同画质体积小 10~20%
RtspTransport tcp tcp 稳定不花屏(推荐),udp 延迟低
IsConnected - (只读)是否已连接
CurrentRecordFile - (只读)当前录制文件路径

体积参考

2K(2560x1440)监控相机,RecordFps=15 + RecordCrf=28 + RecordScale=0.5(1280x720):典型静态场景约 55 kbps,一小时约 25MB;原始分辨率录制约 470 kbps。对比 MJPG 编码同画面约 23 Mbps,体积差约 50 倍。

常见问题

提示"找不到 ffmpeg.exe" 正常装包后会自动复制到输出目录 ffmpeg\ 下。如果你是直接拷贝 dll 用的(没走 NuGet),请手动把包里的 buildTransitive\ffmpeg\ffmpeg.exe 复制到程序目录 ffmpeg\ 下。

画面花屏/丢帧 把 RtspTransport 保持为 tcp。udp 延迟低但网络丢包时会花屏。

录制时长和实际不符 / 文件偏大 确认 RecordFps 没超过相机实际帧率(建议 12~15)。控件按墙钟时间抽帧,时长不会虚高。

许可证说明

控件代码本身可闭源使用。包内自带的 ffmpeg.exe 含 libx264,遵循 GPL 协议:通过进程+管道方式调用属于"简单聚合"(mere aggregation),不传染你的代码;分发时附上 ffmpeg 的 GPL 许可与源码说明(https://ffmpeg.org)即可。如需完全避开 GPL,可联系我们替换为 OpenH264(BSD)编码构建。

Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible.  net9.0-windows 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.
  • net8.0-windows7.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on RtspViewer:

Package Downloads
PCHMI

PCHMI工控组态控件,支持Modbus‑TCP、SIEMENS S7、KEYENCE HOSTLINK、PANASONIC MEWTOCOL、MITSUBISHI MC、OPC Ua、MQTT、BECKHOFF ADS、CODESYS V3、AB LogixE/IP、OMRON FINS E/IP等多种PLC通信协议,快速搭建上位机HMI画面。实时数据采集JSON、EXCEL、SQLITE、MYSQL、POSTGRESQL、SQLSERVER等统一数据库操作接口

PCHMI.Core

PCHMI工控组态控件,支持Modbus‑TCP、SIEMENS S7、KEYENCE HOSTLINK、PANASONIC MEWTOCOL、MITSUBISHI MC、OPC Ua、MQTT、BECKHOFF ADS、CODESYS V3、AB LogixE/IP、OMRON FINS E/IP等多种PLC通信协议,快速搭建上位机HMI画面。实时数据采集JSON、EXCEL、SQLITE、MYSQL、POSTGRESQL、SQLSERVER等统一数据库操作接口

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.1.8 267 10/17/2026
2.1.6 120 10/16/2026
2.1.1 119 10/15/2026
2.1.0 120 10/13/2026
1.0.5 146 10/4/2026
1.0.2 130 10/3/2026