All Projects → davidgatti → How To Stream Movies Using Nodejs

davidgatti / How To Stream Movies Using Nodejs

Licence: mit
🎥 How to Stream Movies to a HTML 5 video tag using NodeJS

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to How To Stream Movies Using Nodejs

Transport Eta
Twitch streamed 🎥playground repo, README speaks to you.
Stars: ✭ 223 (-33.63%)
Mutual labels:  stream, article
How To Understand Streams In Nodejs
🚰 A step by step explanation how to take advantage of Streams in NodeJS
Stars: ✭ 106 (-68.45%)
Mutual labels:  stream, article
Awesome Clojure
list of useful links for clojurians
Stars: ✭ 278 (-17.26%)
Mutual labels:  article
Flutter Widgets
This is a tutorial for all widgets in the flutter. It contain code, articles.
Stars: ✭ 315 (-6.25%)
Mutual labels:  article
Raw Body
Get and validate the raw body of a readable stream
Stars: ✭ 292 (-13.1%)
Mutual labels:  stream
Articles
🔖My Learning Notes and Memories - 分享我的学习片段和与你的回忆
Stars: ✭ 3,040 (+804.76%)
Mutual labels:  article
Legalstream
An m3u8 playlist featuring many LEGALLY FREE IPTV streams. For use with VLC.
Stars: ✭ 299 (-11.01%)
Mutual labels:  stream
Avenging
MVP pattern example on Android: no Dagger or RxJava example
Stars: ✭ 279 (-16.96%)
Mutual labels:  article
Gradio
Stars: ✭ 335 (-0.3%)
Mutual labels:  stream
Weixin Spider
微信公众号爬虫,公众号历史文章,文章评论,文章阅读及在看数据,可视化web页面,可部署于Windows服务器。基于Python3之flask/mysql/redis/mitmproxy/pywin32等实现,高效微信爬虫,微信公众号爬虫,历史文章,文章评论,数据更新。
Stars: ✭ 287 (-14.58%)
Mutual labels:  article
All About Programming
Everything about programming!!
Stars: ✭ 314 (-6.55%)
Mutual labels:  article
Building A Simple Chatbot In Python Using Nltk
Building a Simple Chatbot from Scratch in Python (using NLTK)
Stars: ✭ 286 (-14.88%)
Mutual labels:  article
Facebook Live Reactions
The easiest way to create interactive Facebook live streams. Displays reaction count and live shoutouts :)
Stars: ✭ 284 (-15.48%)
Mutual labels:  stream
Ms17 010 Python
MS17-010: Python and Meterpreter
Stars: ✭ 305 (-9.23%)
Mutual labels:  article
Multistreamer
[discontinued] A webapp for publishing video to multiple streaming services at once.
Stars: ✭ 281 (-16.37%)
Mutual labels:  stream
Mac Local Rtmp Server
Local RTMP Streaming Server
Stars: ✭ 323 (-3.87%)
Mutual labels:  stream
Sweet xml
Stars: ✭ 279 (-16.96%)
Mutual labels:  stream
Understanding Flexbox
💪Detailed Flexbox Book
Stars: ✭ 286 (-14.88%)
Mutual labels:  article
Orion
Cross platform Twitch.tv client
Stars: ✭ 298 (-11.31%)
Mutual labels:  stream
Pyinstalive
Python script to download Instagram livestreams and replays.
Stars: ✭ 336 (+0%)
Mutual labels:  stream

How to Stream a Movie to a HTML 5 video tag using NodeJS

This is a very quick and easy article explaining how to stream movies to an HTML 5 video tag using NodeJS. The whole project is very small and compact. The video.js file is where you shoud focus your attention. The file is in the routes folder.

But first, what are streams?

If you never dealt with streams, you might think to yourself, why not just link the movie file straight to the video tag? If we do that, the whole movie file might be loaded into memory on the server side. Now you may be thinking, but this file is just 30MB in size, so what is the problem?

Well, imagine that you have 16GB of RAM on the server, but you have a 20GB video file on the drive. What now? How would you load such a massive file that exceeds the RAM capacity? Streams are the answer 😎.

With streams, you have your file on disk, sitting there and having a good time. By using the .createReadStream() method, and telling it which part of the file you're interested in, you will just get a chunk of the whole thing. For example, just 1MB. Then you take that 1MB, send it to whoever requested it, and you're done.

If you are interested in learninig more about Streams, check out this other article that I wrote, titled: How-to-Understand-Streams-in-NodeJS.

The high level code explanation

As you can see from the code, the front end part of the project is super basic. The only thing that matters is the HTML 5 video tag and his URL to the resource of the video. Which, in this case, is a URL to a NodeJS route that:

  1. Checks the request to see how much data the video tag requested
  2. Opens the movie file as a stream
  3. Reads the requested chunks
  4. Sends back the data with the response

And this is it. The video tag will keep making requests to the provided URL until it gets the whole movie. The only job for your code is to keep reading parts of the file that the tag asks for.

What this project is not

This article is not a full implementation of the HTTP/1.1 Range Requests standard, meaning that there are edge cases that are not taken into consideration. This document is intended to be a good starting point to help you better understand the basics of this technology.

Deployment

Once you deploy the server on Heroku, you will see the video player in the middle of the page, and you should see the player buffering up with the trailer of Toy Story, which is included in this repo. Replace the movie with another one, but keep in mind that the format of the video must be compatible with what the video tag in your browser is capable of.

The End

If you enjoyed this project, please consider giving it a 🌟. And check out my GitHub account, where you'll find additional resources you might find useful or interesting.

Sponsor 🎊

This project is brought to you by 0x4447 LLC, a software company specializing in building custom solutions on top of AWS. Follow this link to learn more: https://0x4447.com. Alternatively, send an email to [email protected].

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].