How to implement w3c byte range requests?

0

The video plays right. But I can not skip the video time.

Example: Skip time from 05:00 to 10:00.

It just keeps running, and I can not seem to skip the time.

I searched the internet and said that it has to make flow or range or buffer. I do not quite understand that. Link: link

Some say to implement w3c byte range requests. I just do not know where to start.

Follow the code below:

Controller:

[HttpGet]
public EmptyResult StreamUploadedVideo(int num)
{
    byte[] teste = null;
    using (var ctx = new Entities())
    {
        var result = ctx.Table.Where(x => x.Campo == 1).FirstOrDefault();

        teste =  result.Movie;

        HttpContext.Response.AddHeader("Content-Disposition", "attachment; filename=nome.mp4");  //add header to httpcontext > response.
        HttpContext.Response.BinaryWrite(teste);  //write bytes to httpcontext response
        return new EmptyResult();
    }
}

View:

<video width="400" controls>
    <source src="@Url.Action("StreamUploadedVideo","Controller" })" type="video/mp4">
    <p>This browser does not support the video element.</p>
</video>

Can anyone help me?

    
asked by anonymous 06.04.2017 / 07:35

1 answer

1

There are two basic ways to stream video over the web:

    Pseudo Streaming : It takes this name because, in fact, it does not stream, it downloads all binary from the video, progressively, and reproduces according to what the download is happening. In some players you could give pause in the video and wait for all your download to happen, then watch the whole video without buffering . Benefits: It is easier to host and play the videos. It is more expensive to transmit, because you always deliver all the content, even if the whole video is not watched.

  • Adaptive Streaming : This method, instead of downloading all the binary, only downloads chunks - pieces of the video, according to which the playback of the video is happening. This is the technique most used today by YouTube, Netflix, etc. Benefits: Cheaper to stream, you can add various qualities - bitrates - of the video, made them viewable on any bandwidth. Malicious things: More difficult to host, because it requires a specific server for the purpose.

Using Adaptive Streaming, by downloading only pieces, one can request to start downloading from a certain period, rather than always playing from the beginning.

If you want to make things simpler, you can use Azure Media Services for this. Here I did a training on hosting your videos on Azure . Maybe it can streamline your life.

    
06.04.2017 / 09:13