我正在尝试在我的 LibVLC rtsp 流中实现一个记录按钮。录制工作,但是当我尝试录制它时,它只录制 RTSP 流 3 秒,当它录制时,流完全停止。如何在录制 RTSP 流时使其连续流式传输?代码如下。我还在学习 C#,所以请给我一个机会!
void RecordButton_Click(object sender, RoutedEventArgs e)
{
var currentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
var destination = Path.Combine(currentDirectory, "record.mp4");
rtsp1.AddOption(":screen-fps=24");
rtsp1.AddOption(":sout=#transcode{vcodec=h264,vb=0,scale=0,acodec=mp4a,ab=128,channels=2,samplerate=44100}:file{dst=record1.mp4}");
rtsp1.AddOption(":sout-keep");
VideoView2.MediaPlayer.Play(rtsp1); // start recording
//await Task.Delay(5000); // record for 5 seconds
System.Threading.Thread.Sleep(5000);
VideoView2.MediaPlayer.Stop(); // stop recording and saves the file
}