winform下播放RTSP流并截图拍照

播放是使用vlc.Dotnet.forms

 下载这两个

然后工具箱里就多了一个vlc.dotnet.forms

注意在vlc控件的vlclibdirectoryNeeded事件中添加这个

var currentAssesmbly = Assembly.GetEntryAssembly();
            var currentDirectory = new FileInfo(currentAssesmbly.Location).DirectoryName;

            if (null == currentDirectory)
            {
                e.VlcLibDirectory = new DirectoryInfo(Path.GetFullPath(@".\libvlc\win-x86\"));
            }
            else
            {
                e.VlcLibDirectory = new DirectoryInfo(Path.GetFullPath(@".\libvlc\win-x64\"));
            }

            if (!e.VlcLibDirectory.Exists)
            {
                var folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
                folderBrowserDialog.Description = "Select Vlc libraries folder.";
                folderBrowserDialog.RootFolder = Environment.SpecialFolder.Desktop;
                folderBrowserDialog.ShowNewFolderButton = true;
                if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
                {
                    e.VlcLibDirectory = new DirectoryInfo(folderBrowserDialog.SelectedPath);
                }
            }

播放按钮代码

string[] options = { ":network-caching=100", ":rtsp-tcp", ":no-audio" };// { ":network-caching=100", ":rtsp -tcp", ":no-audio" }; //  --avcodec-hw={any,d3d11va,dxva2,none} 
            var videoUri = new Uri(txtUrl1.Text.Trim());
            vlcControl1.Play(videoUri, options);

截图按钮代码

 using(SaveFileDialog sfd = new SaveFileDialog())
            {
                sfd.Filter = "jpg文件 | *.jpg";
                if(sfd.ShowDialog() == DialogResult.OK)
                {
                    vlcControl1.TakeSnapshot(sfd.FileName);
                }
            }

这鬼截图找遍了都没找到,最后还是在哔哩哔哩看视频偶然看到了,这里写出来希望能够帮到别人

暂停和停止都很简单,网上也能找到我就不写了

直接保存可以这样写vlcControl1.TakeSnapshot("D://")这样是保存到了D盘下

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值