I am trying to start a capture of the webcam, transcode it and output it to RTSP
but I cannot view the stream when I view: rtsp://127.0.0.1:53211
I get a log in my VLC player saying:
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.
I don't see any logs in C# side and I see my webcam lights up so I assume it's accessing the webcam.
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();
}
}
}
There were two errors:
media.AddOption(":v4l2-standard=ALL :live-caching=300");
media.AddOption(":sout=#transcode{vcodec=mp2v,acodec=mpga,fps=30}:rtp{mux=ts,sdp=rtsp://:53211}");
Solution in 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");
Command line:
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