All Projects → andreschaffer → media-streaming-examples

andreschaffer / media-streaming-examples

Licence: MIT license
Media Streaming via HTTP Progressive Download in practice.

Programming Languages

java
68154 projects - #9 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to media-streaming-examples

neko
A self hosted virtual browser that runs in docker and uses WebRTC.
Stars: ✭ 2,266 (+14062.5%)
Mutual labels:  media-streaming
sobani
Fully self-hostable and customizable media entertaining stream service based on Node.js for couples, friends, collaboration teams, and even quarantined office workers
Stars: ✭ 22 (+37.5%)
Mutual labels:  media-streaming
cachecontrol
Minimal HTTP cache management library in Scala
Stars: ✭ 13 (-18.75%)
Mutual labels:  http-cache
asgi-caches
Server-side HTTP caching for ASGI applications, inspired by Django's cache framework
Stars: ✭ 18 (+12.5%)
Mutual labels:  http-cache
Nuster
A high performance HTTP proxy cache server and RESTful NoSQL cache server based on HAProxy
Stars: ✭ 1,825 (+11306.25%)
Mutual labels:  http-cache
ultrafetch
Node-based fetch backed with an RFC-7234 compliant filesystem cache.
Stars: ✭ 30 (+87.5%)
Mutual labels:  http-cache
souin
An HTTP cache system, RFC compliant, compatible with @TykTechnologies, @traefik, @caddyserver, @go-chi, @bnkamalesh, @beego, @devfeel, @labstack, @gofiber, @go-goyave, @gin-gonic, @zalando, @zeromicro, @nginx and @apache
Stars: ✭ 269 (+1581.25%)
Mutual labels:  http-cache
fastapi-etag
Convenience library for working with etags in fastapi
Stars: ✭ 19 (+18.75%)
Mutual labels:  http-cache
Neko
A self hosted virtual browser (rabb.it clone) that runs in docker.
Stars: ✭ 1,957 (+12131.25%)
Mutual labels:  media-streaming
playercast
Cast to media player and control playback remotely.
Stars: ✭ 46 (+187.5%)
Mutual labels:  media-streaming

Build Test Coverage Maintainability Dependabot

Media Streaming Examples

Waiting is losing

When serving large media files, it's desirable to allow clients to start playback of the media before the entire file has been downloaded, so that they don't have to wait.
Here we show the use of HTTP Progressive Download to serve videos in that manner.

RFC 7233 - Range Requests

TL;DR flow explanation:

  • The client makes an initial request for a video and receives a server response with no payload so far, but with the headers "Accept-Ranges: bytes" and "Content-Length: video_length_in_bytes" indicating that it accepts range requests to deliver partial contents.
  • The client then makes a range request for the first part of the video using the header "Range: bytes=0-" and receives a 206 Partial Content response back from the server with the bytes corresponding to the first part of the video as payload, together with the header "Content-Range: 0-video_part_byte_end_position/video_length_in_bytes".
  • The client keeps making new requests as the video parts are played, e.g. "Range: bytes=next_video_part_byte_start_position-next_video_part_byte_end_position".
  • Since we are serving potentially large files, it makes sense to take advantage of HTTP caching mechanisms in order to avoid unnecessary retransmissions over the wire. We achieve that via Conditional Requests (RFC 7232, https://github.com/andreschaffer/http-caching-and-concurrency-examples); in this project specifically we explored that with the headers "Last-Modified" and "If-Range".

Remember, not all viewers are equal

This project does not explore adapting playback to the viewers' network conditions. So, depending on their bandwith, even with progressive downloads, buffering waiting times may still happen. A common technique to improve on that is known as Adaptive Bitrate Streaming, which aims to deliver the optimal viewer experience considering their bandwith.

For a complete read about video streaming, check the excellent source HowVideo.works.

Project Requirements

  • Java 14
  • Maven

Trying it out

  • Run ./run.sh .
    This will build, test and run the application. You'll be prompted for the videos directory where you have the mp4 files you want to serve. (Note: there is no pagination in place here, so beware if you are trying to serve a directory with lots of files)
  • Browse to the videos at http://localhost:8080/videos.
  • Pick a video to watch to!
    You can see in your browser Network Panel or in the video progress bar that parts of the video are being downloaded as it gets played.

Contributing

If you would like to help making this project better, see the CONTRIBUTING.md.

Maintainers

Send any other comments, flowers and suggestions to André Schaffer.

License

This project is distributed under the MIT License.

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].