- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经关注了这个 link添加 Vlc.DotNet
库(.Core
、.Core.Interops
、.Forms
和.Wpf
) 添加到我项目的解决方案中。
我还添加了 3.0.0 版本的 VideoLAN.LibVLC.Windows
库。
我在表单中添加了一个 vlcControl,这是生成的 Designer.cs
:
//
// vlcControl1
//
this.vlcControl1.BackColor = System.Drawing.Color.Black;
this.vlcControl1.Location = new System.Drawing.Point(384, 357);
this.vlcControl1.Name = "vlcControl1";
this.vlcControl1.Size = new System.Drawing.Size(75, 23);
this.vlcControl1.Spu = -1;
this.vlcControl1.TabIndex = 6;
this.vlcControl1.Text = "vlcControl1";
this.vlcControl1.VlcLibDirectory = ((System.IO.DirectoryInfo)(resources.GetObject("vlcControl1.VlcLibDirectory")));
this.vlcControl1.VlcMediaplayerOptions = null;
我已经在属性中添加了一个虚拟的 VlcLibDirectory,以便以后可以更改它。
我的 vlcLib 的 x86 版本路径是:E:\testLouka\dansMaCamera2.0\dansMaCamera2.0\libvlc\win-x86
我尝试使用以下代码从 RTSP 流 url 获取视频源:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.vlcControl1 = new VlcControl()
{
Name = "vlc1",
Location = new Point(0, 0),
Dock = DockStyle.Fill,
VlcLibDirectory = new DirectoryInfo(Path.Combine("E:\\testLouka\\dansMaCamera2.0\\dansMaCamera2.0", "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64")),
Spu = -1,
VlcMediaplayerOptions = null,
Enabled = true
};
string[] options = { ":network-caching=500" };
vlcControl1.Play(new Uri(m_stream.URL), options);
}
}
m_stream.URL
变量返回一个类似于“rtsp://admin:admin123@190.19.191.19/Stream0
”的 RTSP 链接
我的表单出现了,但是我的 vlcController 没有显示任何东西......
我看了https://github.com/ZeBobo5/Vlc.DotNet的 wiki,但我卡住了...
我在这里做错了什么?
最佳答案
您所要做的就是将 vlcControl
添加到您的表单,并向其 VlcLibDirectoryNeeded
事件添加一些代码。
/// <summary>
/// Looks for the vlc directory on the opening of the app
/// Opens a dialog if the libvlc folder is not found for the user to pick the good one
/// Folder for 32bits should be "libvlc\win-x86\" and "libvlc\win-x64\" for 64 bits
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void myVlcControl_VlcLibDirectoryNeeded(object sender, VlcLibDirectoryNeededEventArgs e)
{
var currentAssembly = Assembly.GetEntryAssembly();
var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName;
if (currentDirectory == null)
return;
if (IntPtr.Size == 4)
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);
}
}
}
然后,您可以在表单中添加某种播放按钮并播放任何想要的 rtsp 流!
private void btnPlay_Click(object sender, EventArgs e)
{
myVlcControl.Play(MyStream.URL);//can test with rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov
}
如果流媒体链接正常,您应该可以在 Media->Open Network Stream...
下的 VLC 应用程序上流式传输它。
关于c# - 如何使用 Vlc.DotNet 在 Windows Forms c# 中流式传输 RTSP 摄像头源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50412201/
我正在尝试将资源/流设置为 Android 中的墙纸。我使用 WallpaperManager 类及其方法 setResource/setStream 来执行此操作。我通常在将图像设置为墙纸之前使用
我正在编写脚本来通过反复取消对象直到 EOF 来处理(非常大的)文件。我想对文件进行分区并让单独的进程(在云中)解开并处理单独的部分。 但是我的分区器并不智能,它不知道文件中 pickle 对象之间的
我正在实现图形表示。 Map>> g = new HashMap<>(); Graph 类中的一个方法是 List> getAllEdges() { List> allEdges = new
我正在通过 MediaCodec 处理实时流,并且有一个场景,其中 MediaFormat 在流中更改(即:正在解码的视频的分辨率发生更改)。鉴于我将解码器附加到 Surface 以在我检测到传入流的
嗨 iCoders 目前我正在开发一个使用 OpenTok/TokBox iOS SDK 进行直播的应用程序。我怀疑有多少订阅者可以订阅发布者发布的流。我在 openTok 论坛中搜索过这个但是没有找
我是一名优秀的程序员,十分优秀!