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

RTSP Server -Send image 720p #70

Open
AliRoostae opened this issue Nov 13, 2021 · 4 comments
Open

RTSP Server -Send image 720p #70

AliRoostae opened this issue Nov 13, 2021 · 4 comments

Comments

@AliRoostae
Copy link

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 AliRoostae changed the title RTSP Server RTSP Server -Send image 720p Nov 14, 2021
@RogerHardiman
Copy link
Collaborator

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?

@AliRoostae
Copy link
Author

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


        }

@nguyenthaohut
Copy link

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?

@Jaj0
Copy link

Jaj0 commented Mar 10, 2023

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?

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

4 participants