LibVLCSharp:无法查看 RTSP

LibVLCSharp: cannot view the RTSP

我正在尝试开始捕获网络摄像头,对其进行转码并将其输出到 RTSP 但我在查看时无法查看流:rtsp://127.0.0.1:53211

我在我的 VLC 播放器中收到一条日志:

Your input can't be opened:
VLC is unable to open the MRL 'rtsp://127.0.0.1:53211'. Check the log for Your input can't be opened:
VLC is unable to open the MRL 'rtsp://127.0.0.1:53211'. Check the log for details.

我在 C# 端没有看到任何日志,而且我看到我的网络摄像头亮起,所以我假设它正在访问网络摄像头。

using System;
using LibVLCSharp.Shared;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Core.Initialize();

            using var libVlc = new LibVLC();
            using var mediaPlayer = new MediaPlayer(libVlc);

            mediaPlayer.EndReached += (_, x) =>
            {
                Environment.Exit(1);
            };

            var media = new Media(libVlc, "v4l2:///dev/video0", FromType.FromLocation);
            media.AddOption(":v4l2-standard=ALL :live-caching=300");
            media.AddOption(":chroma=mp2v --v4l2-width 1280 --v4l2-height 720");
            media.AddOption(":sout=#transcode{vcodec=mp2v,acodec=mpga,fps=30}:rtp{mux=ts,sdp=rtsp://:53211}");
            media.AddOption(":sout-keep");

            mediaPlayer.Play(media);

            Console.ReadKey();
        }
    }
}

有两个错误:

  1. 此选项格式错误并导致静默错误
media.AddOption(":v4l2-standard=ALL :live-caching=300");
  1. RTSP URL 格式不正确,需要在结尾处添加路径
media.AddOption(":sout=#transcode{vcodec=mp2v,acodec=mpga,fps=30}:rtp{mux=ts,sdp=rtsp://:53211}");

C# 中的解决方案:

var media = new Media(libVlc, "v4l2:///dev/video0", FromType.FromLocation);
media.AddOption(":chroma=mp2v --v4l2-width 1280 --v4l2-height 720");
media.AddOption($"::sout='#transcode{{vcodec=h264,acodec=mpga,ab=128,channels=2,samplerate=44100,scodec=none}}:rtp{{sdp=rtsp://{GetLocalIPAddress()}:53211/live.sdp}}'");
media.AddOption(":no-sout-all");
media.AddOption(":sout-keep");

命令行:

cvlc v4l2:///dev/video0:chroma=mp2v --v4l2-width 1280 --v4l2-height 720 --sout '#transcode{vcodec=h264,acodec=mpga,ab=128,channels=2,samplerate=44100,scodec=none}:rtp{sdp=rtsp://192.168.0.107:53211/live.sdp,proto=tcp}' :no-sout-all :sout-keep