-
Couldn't load subscription status.
- Fork 295
Description
Hello! I am writing a program to conduct a video broadcast from the camera. I decided to transmit data via RTSP. Requests are sent to the server and responses begin to arrive, after receiving, I translate the Frame into a byte[] array and try to convert it to a bitmap, but it gives an error. Can you tell me how I can make a broadcast?
public static async void RTSPClient(CancellationToken token)
{
//параметры и запросы
var serverUri = new Uri("rtsp://192.168.0.94:554/cam0_0");
var credentials = new NetworkCredential("root", "root");
var connectionParameters = new ConnectionParameters(serverUri, credentials);
connectionParameters.RtpTransport = RtpTransportProtocol.TCP;
RtspClient rtspCl1 = new RtspClient(connectionParameters);
try
{
await rtspCl1.ConnectAsync(token);
//the process of obtaining frames
rtspCl1.FrameReceived += (sender, frame) =>
{
switch (frame)
{
case RawH264IFrame h264IFrame:
Console.WriteLine("Формат RawH264IFrame");
//the process of obtaining frames
byte[] cv1 = frame.FrameSegment.Array;
MemoryStream memoryStream = new MemoryStream(fileBytes);
//an error pops up here, the obviously received array is not an image, although the format is RawH264IFrame
Bitmap bitmap = new Bitmap(memoryStream);
break;
default:
Console.WriteLine("Формат неизвестен");
break;
}
};
await rtspCl1.ReceiveAsync(token);
}
catch (SocketException ex)
{
Console.WriteLine("Подключение не установлено");
Console.WriteLine("Код ошибки:");
Console.WriteLine(ex.Message);
}
}