I want to play video using ASP.NET MVC. In my understanding, the model deals with the video files stored in file system and data in database. The controller retrieves the path of video file from model and sends it to the View. So who handles the work of streaming video actually? To find it out, I searched online and found this code sample:

<div width="320" height="240" controls>
      <video>
             <source src="@Url.Content(Model.tbl_Video.VideoPath)" type='video/mp4' />
      </video>
</div>

I think as it's a part of HTML file, it should belong to the View, so can I say that it's the View that actually stream videos in the system?

up vote 0 down vote accepted

ASP.net has nothing to do with video streaming. Video streaming is achieved using intelligent video encoding and manifests in combination with a CDN.

We use:

  1. Flowplayer with HLSJS (Javascript)
  2. CloudFront as the CDN
  3. Encoding.com API to encode videos.
  4. ASP.net on the backend to handle the business logic.

Streaming is usually achieved via an HLS file which is an Apple standard. Think of it as a playlist with several versions of a video. The playlist is composed of 'renditions' that are optimized for various devices and connections, the HLS file then figures out which rendition it should play to provide the best experience for the user.

  • Do you include the videos as part of the ASP.NET project? Or upload it to the CDN manually? – johni Jul 19 '16 at 10:37

What you're seeing in the line of code

<source src="@Url.Content(Model.tbl_Video.VideoPath)" type='video/mp4' />

is just ASP.NET MVC's way to insert the correct source element into a <video> tag.

ASP.NET MVC has no responsibility whatsoever in the streaming process. The browser streams the video content directly.

Further Reading
HTML <video> element

  • The browser streams the video content directly. As I know the browser is on the client side, while the video streamed is stored on the server side. So to stream video the client need to interact with server and receive data from it. Since the controller is used to handle all requests from the client, why it's not involved in this process? – IT_Layman May 6 '16 at 11:13

Yes , Layman correctly marked , browser that having HTML5 video element will start when full data will download. While for progressive/stream/Adaptive download can achieve through HLS ,RTMP prototcal and transcoding media with stream server.

While only progressive download can achieve through video stream in byte to client through MVC controller. Logic need to implement to send data in bytes in chunks and not at whole.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.