c# - 在 C# 中使用 VLC 流式传输网络摄像头
问题描述
我目前正在做一个学校项目,我必须在 C# 中使用 VLC 启动我的网络摄像头流。我面临的主要问题是我认为编解码器(媒体选项)是错误的。每次我尝试在 VLC 中查看我的流时,我都会收到一个错误或一个没有任何音频的黑屏。
代码:
public void StartStream()
{
var currentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
var libDirectory = new DirectoryInfo(Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64"));
using (var mediaPlayer = new VlcMediaPlayer(libDirectory))
{
var mediaOptions = new[]
{
":sout =#transcode{vcodec=h264,scale=Auto,acodec=s16l,ab=128,channels=2,samplerate=44100,scodec=none}",
":rtp{sdp=rtsp:" + _ip + ":8554/live.sdp}",
":no-sout-all",
":sout-keep"
};
//_ip = Local IPv4 Address
mediaPlayer.SetMedia(new Uri(@"dshow://"), mediaOptions);
mediaPlayer.Play();
MessageBox.Show("Streaming on rtsp://" + _ip + ":8554/live");
}
}
亲切的问候,
马尔科
解决方案
推荐阅读
- java - 为什么 Integer 类中的 MIN_VALUE 和 MAX_VALUE 定义为 @native?
- python - 如何使用 Django 在电子邮件中发送 HTML?
- google-sheets - 更改 googlefinance 中的日期格式(历史)
- docker - 在 Docker 中构建 Kotlin JS 项目时任务“:rootPackageJson”执行失败
- laravel - 如何与 belongsToMany 和 belongsToMany 建立深厚的关系
- shopify - Shopify:隐藏缺货的动态链接
- php - php - HTTP 错误 500.19 - 内部服务器错误
- python-3.x - Windows 10 中是否有免费的 Linux 终端来部署 kivy 应用程序
- javascript - 如何使用javascript检查html5画布中的未占用空间?
- python - 如何打印给定特征的类别出现次数?