1 unstable release
0.1.0 | Nov 29, 2024 |
---|
#446 in HTTP server
127 downloads per month
1MB
151 lines
A Rust library for efficient streaming with support for partial content delivery.
Description
A web server built using Actix that allows streaming of video and audio files with support for partial content delivery. This means that clients can request specific byte ranges from the files, enabling features like fast seeking in videos and resuming downloads for audio files.
Features
- Stream video files in MP4 format.
- Stream audio files in MP3 format.
- Support for HTTP byte-range requests for partial content delivery.
- Prefetching for smoother playback by buffering future chunks ahead of the requested range.
- Logging for monitoring requests and errors.
Getting Started
-
Clone the repository:
git clone https://github.com/fadedreams/rsstreamslice.git cd rsstreamslice
-
Add your media files: Place your video and audio files (e.g.,
video.mp4
,mp3.mp3
) in the root directory of the project. -
Build and run the server:
cargo run --bin rsstreamslice_server
-
Access the server: Open your web browser and navigate to:
- http://127.0.0.1:8080/ to stream the video.
- http://127.0.0.1:8080/video for video streaming.
- http://127.0.0.1:8080/mp3 for audio streaming.
API Usage
Endpoints
- GET /: Streams the default video file (video.mp4).
- GET /video: Streams the video file (video.mp4).
- GET /mp3: Streams the audio file (mp3.mp3).
HTTP Headers
Range
: Used to request specific byte ranges from the media files.
Content Types
video/mp4
for MP4 video files.audio/mpeg
for MP3 audio files.
Partial Streaming
This server supports partial streaming, allowing clients to download specific byte ranges of files.
Example curl
commands:
-
To download a part of the video file:
curl -H "Range: bytes=0-1023" http://127.0.0.1:8080 --output video_part.mp4
-
To download the full video file:
curl http://127.0.0.1:8080/video --output full_video.mp4
Logging
The server uses env_logger
for logging. You can set the logging level using the RUST_LOG
environment variable. For example, to enable debug logging, run:
RUST_LOG=debug cargo run --bin rsstreamslice_server
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contributing
Contributions are welcome! Please open an issue or submit a pull request for any enhancements or bug fixes.
Dependencies
~18–30MB
~502K SLoC