A Node.js application to proxy and rewrite .m3u8
streaming URLs. This project allows you to fetch and stream .m3u8
playlists and .ts
segments while rewriting URLs to use the proxy.
- Fetch
.m3u8
playlists and.ts
segments with custom headers. - Rewrite relative URLs in
.m3u8
playlists to use the proxy. - Serve rewritten playlists and segments for seamless streaming.
- Test the proxy using a built-in HTML page with a video player.
- Node.js: Runtime environment.
- Express.js: Web server framework.
- hls.js: JavaScript library for playing HLS streams in browsers.
- node-fetch: Fetch API for Node.js.
- dotenv: Environment variable management.
- Node.js (v16 or higher)
- npm (Node Package Manager)
-
Clone the Repository
git clone https://github.com/MetaHat/m3u8-streaming-proxy.git cd m3u8-streaming-proxy
-
Install Dependencies
npm install
-
Set Up Environment Variables
- Create a
.env
file in the root directory:PORT=3000
- Create a
-
Start the Server
- For development (with auto-restart):
npm run dev
- For production:
npm start
- For development (with auto-restart):
-
Access the Application
- Open your browser and navigate to:
http://localhost:3000
- Open your browser and navigate to:
-
Make a GET request to the proxy endpoint with the
url
query parameter:http://localhost:3000/api/v1/streamingProxy?url=<your-m3u8-url>
-
Example:
http://localhost:3000/api/v1/streamingProxy?url=https://example.com/stream/playlist.m3u8
- Open the HTML page at
http://localhost:3000
. - Enter a
.m3u8
URL in the input field and click "Load Stream". - The video will load and play in the video player.
- Description: Proxies and rewrites
.m3u8
playlists and.ts
segments. - Query Parameters:
url
: The URL of the.m3u8
playlist or.ts
segment.
- Response:
- For
.m3u8
playlists: Rewritten playlist with proxy URLs. - For
.ts
segments: The segment file.
- For
- Big Buck Bunny:
https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8
- Apple Sample:
https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Commit your changes.
- Submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
- Made by Metahat.
- Built with ❤️ and open-source tools.
If you encounter any issues or have questions, please open an issue on GitHub.