軟件特色
1. 簡明輕巧(只需更改配置文件的視頻流地址就能播放;使用高性能rtsp播放器,開流關流瞬開,延時更低(200ms內),軟解CPU占用更低,支持rtsp及rtmp)
2. 自適應屏幕分辨率
3. 自定義分屏及任意更改某一路視頻流地址
代碼部分
<?xml version="1.0" encoding="utf-8" ?> <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /> </startup> <appSettings> <add key="ScreenMaxNum" value="32" /> <add key="VideoUrl1" value="rtsp://admin:thzn123456@192.168.0.13:554/h264/ch1/main/av_stream" /> <add key="VideoUrl2" value="rtsp://admin:thzn123456@192.168.0.11:554/h264/ch1/main/av_stream" /> <add key="VideoUrl3" value="rtsp://admin:thzn123456@192.168.0.12:554/h264/ch1/main/av_stream" /> <add key="VideoUrl4" value="rtsp://admin:thzn123456@192.168.0.12:554/h264/ch1/main/av_stream" /> <add key="VideoUrl5" value="rtsp://admin:thzn123456@192.168.0.13:554/h264/ch1/main/av_stream" /> <add key="VideoUrl6" value="rtsp://admin:thzn123456@192.168.0.13:554/h264/ch1/main/av_stream" /> <add key="VideoUrl7" value="rtsp://admin:thzn123456@192.168.0.20/cam/realmonitor?channel=1&subtype=0" /> <add key="VideoUrl8" value="rtsp://admin:thzn123456@192.168.0.20/cam/realmonitor?channel=1&subtype=0" /> <add key="VideoUrl9" value="rtsp://admin:thzn123456@192.168.0.21/cam/realmonitor?channel=1&subtype=0" /> <add key="VideoUrl10" value="rtsp://admin:thzn123456@192.168.0.21/cam/realmonitor?channel=1&subtype=0" /> <add key="VideoUrl11" value="rtsp://admin:thzn123456@192.168.0.11:554/h264/ch1/main/av_stream" /> <add key="VideoUrl12" value="rtsp://admin:thzn123456@192.168.0.12:554/h264/ch1/main/av_stream" /> <add key="VideoUrl13" value="rtsp://admin:thzn123456@192.168.0.13:554/h264/ch1/main/av_stream" /> <add key="VideoUrl14" value="rtsp://admin:thzn123456@192.168.0.11:554/h264/ch1/main/av_stream" /> <add key="VideoUrl15" value="rtsp://admin:thzn123456@192.168.0.20/cam/realmonitor?channel=1&subtype=0" /> <add key="VideoUrl16" value="rtsp://admin:thzn123456@192.168.0.21/cam/realmonitor?channel=1&subtype=0" /> <add key="VideoUrl17" value="" /> <add key="VideoUrl18" value="" /> <add key="VideoUrl19" value="" /> <add key="VideoUrl20" value="" /> <add key="VideoUrl21" value="" /> <add key="VideoUrl22" value="" /> <add key="VideoUrl23" value="" /> <add key="VideoUrl24" value="" /> <add key="VideoUrl25" value="" /> <add key="VideoUrl26" value="" /> <add key="VideoUrl26" value="" /> <add key="VideoUrl28" value="" /> <add key="VideoUrl29" value="" /> <add key="VideoUrl30" value="" /> <add key="VideoUrl31" value="" /> <add key="VideoUrl32" value="" /> </appSettings> </configuration>
using System; using System.Collections.Generic; using System.Configuration; using System.Windows.Forms; namespace RtspPlayerPro { public partial class MainForm : Form { // 視頻流數據字典 Dictionary<int, string> dicVideo = new Dictionary<int, string>(); public MainForm() { InitializeComponent(); // 適配屏幕分辨率 this.Width = SystemInformation.VirtualScreen.Width; this.Height = SystemInformation.VirtualScreen.Height; this.Location = new System.Drawing.Point(0, 0); AutoScreenSize.AutoControls(this); } private void MainForm_Load(object sender, EventArgs e) { // 加載視頻流數據 int ScreenMaxNum = Convert.ToInt32(ConfigurationManager.AppSettings["ScreenMaxNum"]); for (int i = 0; i < ScreenMaxNum; i++) { var url = ConfigurationManager.AppSettings["VideoUrl" + (i + 1).ToString()]; if (null != url) { dicVideo.Add(i, url); } } previewScreen1.DispalyMonitor(1);// 默認1畫面 cmbScreenNum.SelectedIndex = 0; } private void cmbScreenNum_SelectedIndexChanged(object sender, EventArgs e) { // 播放布局更新 previewScreen1.CloseAllMonitor(); int ScreenNum = Convert.ToInt32(cmbScreenNum.Text); previewScreen1.DispalyMonitor(ScreenNum); foreach (KeyValuePair<int, string> video in dicVideo) { if (video.Key > (ScreenNum - 1)) break; previewScreen1.AddPreviewPlayer(video.Key, video.Value); } } private void btnPlay_Click(object sender, EventArgs e) { // 播放線路更新 int videoIndex = Convert.ToInt32(txtVideoIndex.Text) - 1; if (videoIndex < 0) videoIndex = 0; string videoUrl = txtVideoUrl.Text; previewScreen1.AddPreviewPlayer(videoIndex, videoUrl); // 同步更新到視頻流數據字典 dicVideo[videoIndex] = videoUrl; } } }
程序架構
軟件運行
32路測試
電腦配置