SharpRTSP icon indicating copy to clipboard operation
SharpRTSP copied to clipboard

RTSP Server -Send image 720p

Open AliRoostae opened this issue 3 years ago • 4 comments

Hi, Thanks for your good library It really helped me. Now I can send my photos with your help. But I have a problem with resolutions above 720p. I tried to do this with TCP but failed. Please help in this regard

AliRoostae avatar Nov 13 '21 15:11 AliRoostae

Can you explain how your software currently works. For example, how are you converting your photos to YUV format to feed into the example h264 encoder. Or are you using a different H264 encoder?

RogerHardiman avatar Dec 24 '21 13:12 RogerHardiman

Can you explain how your software currently works. For example, how are you converting your photos to YUV format to feed into the example h264 encoder. Or are you using a different H264 encoder?

Hello . I came to this conclusion

byte[] Y_y = new byte[y_size];
        byte[] U_u = new byte[u_size];
        byte[] V_v = new byte[v_size];
        Bitmap img = new Bitmap("1.jpg");
        int loop = 0;
        int loopVU = 0;
        for (int i = 0; i < img.Height; i++)
        {
            for (int j = 0; j < img.Width; j++)
            {
                var cloPix = img.GetPixel(j, i);
                int Y = ((66 * cloPix.R + 129 * cloPix.G + 25 * cloPix.B + 128) >> 8) + 16;
                var U = ((-38 * cloPix.R - 74 * cloPix.G + 112 * cloPix.B + 128) >> 8) + 128;
                var V = (0.439 * cloPix.R) - (0.368 * cloPix.G) - (0.071 * cloPix.B) + 128;
                Y_y[loop++] = (byte)Y;
                if (i % 2 == 0 && j % 2 == 0)
                {
                    var cloPix2 = img.GetPixel(j, i);
                    U_u[loopVU] = (byte)U;
                    V_v[loopVU] = (byte)V;
                    loopVU++;
                }
            }
        }

        // Set all values to 127

        for (int x = 0; x < yuv_frame.Length; x++)
        {

            if (y_size > x)
            {

                yuv_frame[x] =/* 127;//*/ Y_y[x];
            }

            else if (y_size + u_size > x)
            {

                yuv_frame[x] = /*127;//*/ U_u[x- y_size];

            }
            else yuv_frame[x] = /*127;//*/V_v[x - (y_size+ u_size)];


        }

AliRoostae avatar Jan 08 '22 08:01 AliRoostae

I can use OpenH264Lib to encode from image to video up to 1080p video but SharpRTSP just can carry upto 640x480 video, can you help me to find where is the problem?

nguyenthaohut avatar Jun 24 '22 09:06 nguyenthaohut

I can use OpenH264Lib to encode from image to video up to 1080p video but SharpRTSP just can carry upto 640x480 video, can you help me to find where is the problem?

Hi,

in RstpServer.cs around line 635 there are such lines: // INDIGO VISION DOES NOT SUPPORT FRAGMENTATION. Send as one jumbo RTP packet and let OS split over MTUs. // NOTE TO SELF... perhaps this was because the SDP did not have the extra packetization flag fragmenting = false; you need to comment this fragmenting = false;

then you will be able to send bigger frames.

In exchange, can you tell me how you adapted this sample code to use OpenH264Lib?

Jaj0 avatar Mar 10 '23 10:03 Jaj0