Change the quality of a video stream c#

Asked

Viewed 210 times

5

I need to change the quality of a video that is being aired by my Api, I’m already sending the file, now I need to change the quality of it at the time of transmission, follow my code below:

               var buffer = new byte[65536];

                using (var video = File.Open(_filename, FileMode.Open, FileAccess.Read))
                {
                    var length = (int)video.Length;
                    var bytesRead = 1;

                    while (length > 0 && bytesRead > 0)
                    {
                        bytesRead = video.Read(buffer, 0, Math.Min(length, buffer.Length));
                        await outputStream.WriteAsync(buffer, 0, bytesRead);
                        length -= bytesRead;
                    }
                }

Is there any way to change at the time of streaming or I need to have it physically in the other qualities?

  • 2

    Normally, video quality is not defined by the way you feed the buffer, and yes by the sample rate of the video. It means that you have to work that buffer somehow before.

  • I got it, I’m gonna see a shape here and then I’m gonna shape it, see...

1 answer

1


As the Gypsy Morrison commented. The quality of the video not set at the time of transmitting the stream, but in the video.

If you are using physical files you will need to have "copies" of them encoded with the features you expect. You can even automate the process using ffmpeg library

For live broadcasts you can set up in your enconder profiles, various endpoints for quality variations or deliver content on Tracks presented in a manifesto for Adaptative bitrate Streaming or Smooth Stream.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.