Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can't get to play the video #132

Open
EgorBlagodarov opened this issue Nov 9, 2023 · 1 comment
Open

I can't get to play the video #132

EgorBlagodarov opened this issue Nov 9, 2023 · 1 comment

Comments

@EgorBlagodarov
Copy link

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);

}
}

@Revan1985
Copy link

Revan1985 commented Nov 28, 2023

Hello Egor,
you cannot take a rawh264iframe and write directly in a bitmap.
there is an example SimpleRtspPlayer that you can use as reference on how to archive your needs.
I think you need the RawFramesDecoding folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants