---
title: MediaFlow Proxy
emoji: 🎥
colorFrom: blue
colorTo: green
sdk: docker
app_port: 8888
pinned: false
license: mit
thumbnail: >-
https://cdn.githubraw.com/mhdzumair/mediaflow-proxy/main/mediaflow_proxy/static/logo.png
---
# MediaFlow Proxy
<div style="text-align: center;">
<img src="https://cdn.githubraw.com/mhdzumair/mediaflow-proxy/main/mediaflow_proxy/static/logo.png" alt="MediaFlow Proxy Logo" width="200" style="border-radius: 15px;">
</div>
MediaFlow Proxy is a powerful and flexible solution for proxifying various types of media streams. It supports HTTP(S) links, HLS (M3U8) streams, and MPEG-DASH streams, including DRM-protected content. This proxy can convert MPEG-DASH DRM-protected streams to decrypted HLS live streams in real-time, making it one of the fastest live decrypter servers available.
## Features
### Stream Processing
- Convert MPEG-DASH streams (DRM-protected and non-protected) to HLS
- Support for Clear Key DRM-protected MPD DASH streams
- Support for non-DRM protected DASH live and VOD streams
- Proxy and modify HLS (M3U8) streams in real-time
- Proxy HTTP/HTTPS links with custom headers
### Proxy & Routing
- Advanced proxy routing system with support for:
- Domain-based routing rules
- Protocol-specific routing (HTTP/HTTPS)
- Subdomain and wildcard patterns
- Port-specific routing
- Support for HTTP/HTTPS/SOCKS5 proxy forwarding
- Flexible SSL verification control per route
- Support for expired or self-signed SSL certificates
- Public IP address retrieval for Debrid services integration
### Security
- API password protection against unauthorized access & Network bandwidth abuse prevention
- Parameter encryption to hide sensitive information
- Optional IP-based access control for encrypted URLs
- URL expiration support for encrypted URLs
### Additional Features
- Built-in speed test for RealDebrid and AllDebrid services
- Custom header injection and modification
- Real-time HLS manifest manipulation
- HLS Key URL modifications for bypassing stream restrictions
## Configuration
Set the following environment variables:
- `API_PASSWORD`: Required. Protects against unauthorized access and API network abuses.
- `ENABLE_STREAMING_PROGRESS`: Optional. Enable streaming progress logging. Default is `false`.
### Transport Configuration
MediaFlow Proxy now supports advanced transport configuration using HTTPX's routing system. You can configure proxy and SSL verification settings for different domains and protocols.
#### Basic Configuration
Enable proxy for all routes:
```env
PROXY_URL=http://proxy:8080
ALL_PROXY=true
```
#### Advanced Routing Configuration
Configure different proxy settings for specific patterns:
```env
PROXY_URL=http://proxy:8080
TRANSPORT_ROUTES='{
"https://internal.company.com": {
"proxy": false
},
"all://streaming.service.com": {
"proxy_url": "socks5://streaming-proxy:1080",
"verify_ssl": false
}
}'
```
The routing system supports various patterns:
- Domain routing: `"all://example.com"`
- Subdomain routing: `"all://*.example.com"`
- Protocol-specific routing: `"https://example.com"`
- Port-specific routing: `"all://*:1234"`
- Wildcard routing: `"all://"`
#### Route Configuration Options
Each route can have the following settings:
- `proxy`: Boolean to enable/disable proxy for this route (default: true)
- `proxy_url`: Optional specific proxy URL for this route (overrides primary proxy_url)
- `verify_ssl`: Boolean to control SSL verification (default: true)
#### Configuration Examples
1. Simple proxy setup with SSL bypass for internal domain:
```env
PROXY_URL=http://main-proxy:8080
TRANSPORT_ROUTES='{
"https://internal.domain.com": {
"proxy": false,
"verify_ssl": false
}
}'
```
2. Different proxies for different services:
```env
PROXY_URL=http://default-proxy:8080
TRANSPORT_ROUTES='{
"all://*.streaming.com": {
"proxy": true,
"proxy_url": "socks5://streaming-proxy:1080"
},
"all://*.internal.com": {
"proxy": false
},
"https://api.service.com": {
"proxy": true,
"verify_ssl": false
}
}'
```
3. Global proxy with exceptions:
```env
PROXY_URL=http://main-proxy:8080
ALL_PROXY=true
TRANSPORT_ROUTES='{
"all://local.network": {
"proxy": false
},
"all://*.trusted-service.com": {
"proxy": false
}
}'
```
### Speed Test Feature
MediaFlow Proxy now includes a built-in speed test feature for testing RealDebrid and AllDebrid network speeds. To access the speed test:
1. Open your browser and navigate to `http://your-server:8888/speedtest.html`
2. The speed test page allows you to:
- Test download speeds from RealDebrid servers
- Test download speeds from AllDebrid servers
## Installation
### Option 1: Self-Hosted Deployment
#### Using Docker from Docker Hub
1. Pull & Run the Docker image:
```
docker run -p 8888:8888 -e API_PASSWORD=your_password mhdzumair/mediaflow-proxy
```
#### Using pip
> [!IMPORTANT]
> Ensure that you have Python 3.10 or higher installed.
1. Install the package:
```
pip install mediaflow-proxy
```
2. Set the `API_PASSWORD` and other environment variables in `.env`:
```
echo "API_PASSWORD=your_password" > .env
```
3. Run the MediaFlow Proxy server:
```
mediaflow-proxy
```
You can access the server at `http://localhost:8888`.
4. To run the server with uvicorn options: (Optional)
```
uvicorn mediaflow_proxy.main:app --host 0.0.0.0 --port 8888 --workers 4
```
#### Using git & poetry
> [!IMPORTANT]
> Ensure that you have Python 3.10 or higher installed.
1. Clone the repository:
```
git clone https://github.com/mhdzumair/mediaflow-proxy.git
cd mediaflow-proxy
```
2. Install dependencies using Poetry:
```
poetry install
```
3. Set the `API_PASSWORD` environment variable in `.env`:
```
echo "API_PASSWORD=your_password" > .env
```
4. Run the FastAPI server:
```
poetry run uvicorn mediaflow_proxy.main:app --host 0.0.0.0 --port 8888 --workers 4
```
#### Build and Run Docker Image Locally
1. Build the Docker image:
```
docker build -t mediaflow-proxy .
```
2. Run the Docker container:
```
docker run -d -p 8888:8888 -e API_PASSWORD=your_password --restart unless-stopped --name mediaflow-proxy mediaflow-proxy
```
### Option 2: Premium Hosted Service (ElfHosted)
<div style="text-align: center;">
<img src="https://store.elfhosted.com/wp-content/uploads/2024/08/mediaflow-proxy.jpg" alt="ElfHosted Logo" width="200" style="border-radius: 15px;">
</div>
For a hassle-free, high-performance deployment of MediaFlow Proxy, consider the premium hosted service through ElfHosted.
To purchase:
1. Visit [https://store.elfhosted.com/product/mediaflow-proxy](https://store.elfhosted.com/product/mediaflow-proxy)
2. Follow ElfHosted's setup instructions
Benefits:
- Instant setup and automatic updates
- High performance and 24/7 availability
- No server maintenance required
Ideal for users who want a reliable, plug-and-play solution without the technical overhead of self-hosting.
### Option 3: Hugging Face Space Deployment
1. Visit the HF Space: [mhdzumair/mediaflow-proxy](https://huggingface.co/spaces/mhdzumair/mediaflow-proxy)
2. Click on three dots on the right side of the page and select "Duplicate Space"
3. Set the `API_PASSWORD` secret value & Set Visibility to "Public"
4. Click on "Duplicate Space" to deploy the API
## Usage
### Endpoints
1. `/proxy/hls/manifest.m3u8`: Proxify HLS streams
2. `/proxy/stream`: Proxy generic http video streams
3. `/proxy/mpd/manifest.m3u8`: Process MPD manifests
4. `/proxy/mpd/playlist.m3u8`: Generate HLS playlists from MPD
5. `/proxy/mpd/segment.mp4`: Process and decrypt media segments
6. `/proxy/ip`: Get the public IP address of the MediaFlow Proxy server
Once the server is running, for more details on the available endpoints and their parameters, visit the Swagger UI at `http://localhost:8888/docs`.
### Examples
#### Proxy HTTPS Stream
```bash
mpv "http://localhost:8888/proxy/stream?d=https://jsoncompare.org/LearningContainer/SampleFiles/Video/MP4/sample-mp4-file.mp4&api_password=your_password"
```
#### Proxy HTTPS self-signed certificate Stream
To bypass SSL verification for a self-signed certificate stream, export the proxy route configuration:
```bash
PROXY_ROUTES='{"https://self-signed.badssl.com": {"proxy_url": null, "verify_ssl": false}}'
```
```bash
mpv "http://localhost:8888/proxy/stream?d=https://self-signed.badssl.com/&api_password=your_password"
```
#### Proxy HLS Stream with Headers
```bash
mpv "http://localhost:8888/proxy/hls/manifest.m3u8?d=https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8&h_referer=https://apple.com/&h_origin=https://apple.com&h_user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36&api_password=your_password"
```
#### Live DASH Stream (Non-DRM Protected)
```bash
mpv -v "http://localhost:8888/proxy/mpd/manifest.m3u8?d=https://livesim.dashif.org/livesim/chunkdur_1/ato_7/testpic4_8s/Manifest.mpd&api_password=your_password"
```
#### VOD DASH Stream (DRM Protected)
```bash
mpv -v "http://localhost:8888/proxy/mpd/manifest.m3u8?d=https://media.axprod.net/TestVectors/v7-MultiDRM-SingleKey/Manifest_1080p_ClearKey.mpd&key_id=nrQFDeRLSAKTLifXUIPiZg&key=FmY0xnWCPCNaSpRG-tUuTQ&api_password=your_password"
```
Note: The `key` and `key_id` parameters are automatically processed if they're not in the correct format.
### URL Encoding
For players like VLC that require properly encoded URLs, use the `encode_mediaflow_proxy_url` function:
```python
from mediaflow_proxy.utils.http_utils import encode_mediaflow_proxy_url
encoded_url = encode_mediaflow_proxy_url(
mediaflow_proxy_url="http://127.0.0.1:8888",
endpoint="/proxy/mpd/manifest.m3u8",
destination_url="https://media.axprod.net/TestVectors/v7-MultiDRM-SingleKey/Manifest_1080p_ClearKey.mpd",
query_params={
"key_id": "nrQFDeRLSAKTLifXUIPiZg",
"key": "FmY0xnWCPCNaSpRG-tUuTQ",
"api_password": "your_password"
},
request_headers={
"referer": "https://media.axprod.net/",
"origin": "https://media.axprod.net",
}
)
print(encoded_url)
# http://127.0.0.1:8888/proxy/mpd/manifest.m3u8?key_id=nrQFDeRLSAKTLifXUIPiZg&key=FmY0xnWCPCNaSpRG-tUuTQ&api_password=your_password&d=https%3A%2F%2Fmedia.axprod.net%2FTestVectors%2Fv7-MultiDRM-SingleKey%2FManifest_1080p_ClearKey.mpd&h_referer=https%3A%2F%2Fmedia.axprod.net%2F&h_origin=https%3A%2F%2Fmedia.axprod.net
```
This will output a properly encoded URL that can be used with players like VLC.
```bash
vlc "http://127.0.0.1:8888/proxy/mpd/manifest.m3u8?key_id=nrQFDeRLSAKTLifXUIPiZg&key=FmY0xnWCPCNaSpRG-tUuTQ&api_password=dedsec&d=https%3A%2F%2Fmedia.axprod.net%2FTestVectors%2Fv7-MultiDRM-SingleKey%2FManifest_1080p_ClearKey.mpd"
```
### Generating Encrypted URLs
To generate an encrypted URL with optional IP restriction and expiration, Use the `/generate_encrypted_or_encoded_url` endpoint via swagger UI or programmatically as shown below:
```python
import requests
url = "http://localhost:8888/generate_encrypted_or_encoded_url"
data = {
"mediaflow_proxy_url": "http://localhost:8888",
"endpoint": "/proxy/mpd/manifest.m3u8",
"destination_url": "https://media.axprod.net/TestVectors/v7-MultiDRM-SingleKey/Manifest_1080p_ClearKey.mpd",
"query_params": {
"key_id": "nrQFDeRLSAKTLifXUIPiZg",
"key": "FmY0xnWCPCNaSpRG-tUuTQ"
},
"request_headers": {
"referer": "https://media.axprod.net/",
"origin": "https://media.axprod.net",
},
"expiration": 3600, # URL will expire in 1 hour
"ip": "123.123.123.123", # Optional: Restrict access to this IP
"api_password": "your_password"
}
response = requests.post(url, json=data)
encrypted_url = response.json()["encoded_url"]
print(encrypted_url)
```
You can then use the `encoded_url` in your player or application to access the media stream.
### Using MediaFlow Proxy with Debrid Services and Stremio Addons
MediaFlow Proxy can be particularly useful when working with Debrid services (like Real-Debrid, AllDebrid) and Stremio addons. The `/proxy/ip` endpoint allows you to retrieve the public IP address of the MediaFlow Proxy server, which is crucial for routing Debrid streams correctly.
When a Stremio addon needs to create a video URL for a Debrid service, it typically needs to provide the user's public IP address. However, when routing the Debrid stream through MediaFlow Proxy, you should use the IP address of the MediaFlow Proxy server instead.
Here's how to utilize MediaFlow Proxy in this scenario:
1. If MediaFlow Proxy is accessible over the internet:
- Use the `/proxy/ip` endpoint to get the MediaFlow Proxy server's public IP.
- Use this IP when creating Debrid service URLs in your Stremio addon.
2. If MediaFlow Proxy is set up locally:
- Stremio addons can directly use the client's IP address.
## Future Development
- Add support for Widevine and PlayReady decryption
## Acknowledgements and Inspirations
MediaFlow Proxy was developed with inspiration from various projects and resources:
- [Stremio Server](https://github.com/Stremio/stremio-server) for HLS Proxify implementation, which inspired our HLS M3u8 Manifest parsing and redirection proxify support.
- [Comet Debrid proxy](https://github.com/g0ldyy/comet) for the idea of proxifying HTTPS video streams.
- [mp4decrypt](https://www.bento4.com/developers/dash/encryption_and_drm/), [mp4box](https://wiki.gpac.io/xmlformats/Common-Encryption/), and [devine](https://github.com/devine-dl/devine) for insights on parsing MPD and decrypting Clear Key DRM protected content.
- Test URLs were sourced from:
- [OTTVerse MPEG-DASH MPD Examples](https://ottverse.com/free-mpeg-dash-mpd-manifest-example-test-urls/)
- [OTTVerse HLS M3U8 Examples](https://ottverse.com/free-hls-m3u8-test-urls/)
- [Bitmovin Stream Test](https://bitmovin.com/demos/stream-test)
- [Bitmovin DRM Demo](https://bitmovin.com/demos/drm)
- [DASH-IF Reference Player](http://reference.dashif.org/dash.js/nightly/samples/)
- [HLS Protocol RFC](https://www.rfc-editor.org/rfc/rfc8216) for understanding the HLS protocol specifications.
- Claude 3.5 Sonnet for code assistance and brainstorming.
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## License
[MIT License](LICENSE)
## Disclaimer
This project is for educational purposes only. The developers of MediaFlow Proxy are not responsible for any misuse of this software. Please ensure that you have the necessary permissions to access and use the media streams you are proxying.
Raw data
{
"_id": null,
"home_page": "https://github.com/mhdzumair/mediaflow-proxy",
"name": "mediaflow-proxy",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "proxy, media, streaming, hls, dash, drm",
"author": "mhdzumair",
"author_email": "mhdzumair@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/b1/87/ed7ac9973e250e11127c8d750698c13f4fa8850d27a296a02ba0687d48ba/mediaflow_proxy-1.9.4.tar.gz",
"platform": null,
"description": "---\ntitle: MediaFlow Proxy\nemoji: \ud83c\udfa5\ncolorFrom: blue\ncolorTo: green\nsdk: docker\napp_port: 8888\npinned: false\nlicense: mit\nthumbnail: >-\n https://cdn.githubraw.com/mhdzumair/mediaflow-proxy/main/mediaflow_proxy/static/logo.png\n---\n\n\n# MediaFlow Proxy\n\n<div style=\"text-align: center;\">\n <img src=\"https://cdn.githubraw.com/mhdzumair/mediaflow-proxy/main/mediaflow_proxy/static/logo.png\" alt=\"MediaFlow Proxy Logo\" width=\"200\" style=\"border-radius: 15px;\">\n</div>\n\nMediaFlow Proxy is a powerful and flexible solution for proxifying various types of media streams. It supports HTTP(S) links, HLS (M3U8) streams, and MPEG-DASH streams, including DRM-protected content. This proxy can convert MPEG-DASH DRM-protected streams to decrypted HLS live streams in real-time, making it one of the fastest live decrypter servers available.\n\n## Features\n\n### Stream Processing\n- Convert MPEG-DASH streams (DRM-protected and non-protected) to HLS\n- Support for Clear Key DRM-protected MPD DASH streams\n- Support for non-DRM protected DASH live and VOD streams\n- Proxy and modify HLS (M3U8) streams in real-time\n- Proxy HTTP/HTTPS links with custom headers\n\n### Proxy & Routing\n- Advanced proxy routing system with support for:\n - Domain-based routing rules\n - Protocol-specific routing (HTTP/HTTPS)\n - Subdomain and wildcard patterns\n - Port-specific routing\n- Support for HTTP/HTTPS/SOCKS5 proxy forwarding\n- Flexible SSL verification control per route\n- Support for expired or self-signed SSL certificates\n- Public IP address retrieval for Debrid services integration\n\n### Security\n- API password protection against unauthorized access & Network bandwidth abuse prevention\n- Parameter encryption to hide sensitive information\n- Optional IP-based access control for encrypted URLs\n- URL expiration support for encrypted URLs\n\n### Additional Features\n- Built-in speed test for RealDebrid and AllDebrid services\n- Custom header injection and modification\n- Real-time HLS manifest manipulation\n- HLS Key URL modifications for bypassing stream restrictions\n\n\n## Configuration\n\nSet the following environment variables:\n\n- `API_PASSWORD`: Required. Protects against unauthorized access and API network abuses.\n- `ENABLE_STREAMING_PROGRESS`: Optional. Enable streaming progress logging. Default is `false`.\n\n### Transport Configuration\n\nMediaFlow Proxy now supports advanced transport configuration using HTTPX's routing system. You can configure proxy and SSL verification settings for different domains and protocols.\n\n#### Basic Configuration\n\nEnable proxy for all routes:\n```env\nPROXY_URL=http://proxy:8080\nALL_PROXY=true\n```\n\n#### Advanced Routing Configuration\n\nConfigure different proxy settings for specific patterns:\n```env\nPROXY_URL=http://proxy:8080\nTRANSPORT_ROUTES='{\n \"https://internal.company.com\": {\n \"proxy\": false\n },\n \"all://streaming.service.com\": {\n \"proxy_url\": \"socks5://streaming-proxy:1080\",\n \"verify_ssl\": false\n }\n}'\n```\n\nThe routing system supports various patterns:\n- Domain routing: `\"all://example.com\"`\n- Subdomain routing: `\"all://*.example.com\"`\n- Protocol-specific routing: `\"https://example.com\"`\n- Port-specific routing: `\"all://*:1234\"`\n- Wildcard routing: `\"all://\"`\n\n#### Route Configuration Options\n\nEach route can have the following settings:\n- `proxy`: Boolean to enable/disable proxy for this route (default: true)\n- `proxy_url`: Optional specific proxy URL for this route (overrides primary proxy_url)\n- `verify_ssl`: Boolean to control SSL verification (default: true)\n\n#### Configuration Examples\n\n1. Simple proxy setup with SSL bypass for internal domain:\n```env\nPROXY_URL=http://main-proxy:8080\nTRANSPORT_ROUTES='{\n \"https://internal.domain.com\": {\n \"proxy\": false,\n \"verify_ssl\": false\n }\n}'\n```\n\n2. Different proxies for different services:\n```env\nPROXY_URL=http://default-proxy:8080\nTRANSPORT_ROUTES='{\n \"all://*.streaming.com\": {\n \"proxy\": true,\n \"proxy_url\": \"socks5://streaming-proxy:1080\"\n },\n \"all://*.internal.com\": {\n \"proxy\": false\n },\n \"https://api.service.com\": {\n \"proxy\": true,\n \"verify_ssl\": false\n }\n}'\n```\n\n3. Global proxy with exceptions:\n```env\nPROXY_URL=http://main-proxy:8080\nALL_PROXY=true\nTRANSPORT_ROUTES='{\n \"all://local.network\": {\n \"proxy\": false\n },\n \"all://*.trusted-service.com\": {\n \"proxy\": false\n }\n}'\n```\n\n### Speed Test Feature\n\nMediaFlow Proxy now includes a built-in speed test feature for testing RealDebrid and AllDebrid network speeds. To access the speed test:\n\n1. Open your browser and navigate to `http://your-server:8888/speedtest.html`\n2. The speed test page allows you to:\n - Test download speeds from RealDebrid servers\n - Test download speeds from AllDebrid servers\n\n\n## Installation\n\n### Option 1: Self-Hosted Deployment\n\n#### Using Docker from Docker Hub\n\n1. Pull & Run the Docker image:\n ```\n docker run -p 8888:8888 -e API_PASSWORD=your_password mhdzumair/mediaflow-proxy\n ```\n\n#### Using pip\n\n> [!IMPORTANT] \n> Ensure that you have Python 3.10 or higher installed.\n\n1. Install the package:\n ```\n pip install mediaflow-proxy\n ```\n\n2. Set the `API_PASSWORD` and other environment variables in `.env`:\n ```\n echo \"API_PASSWORD=your_password\" > .env\n ```\n\n3. Run the MediaFlow Proxy server:\n ```\n mediaflow-proxy\n ```\n You can access the server at `http://localhost:8888`.\n\n4. To run the server with uvicorn options: (Optional)\n ```\n uvicorn mediaflow_proxy.main:app --host 0.0.0.0 --port 8888 --workers 4\n ```\n\n\n#### Using git & poetry\n\n> [!IMPORTANT] \n> Ensure that you have Python 3.10 or higher installed.\n\n\n1. Clone the repository:\n ```\n git clone https://github.com/mhdzumair/mediaflow-proxy.git\n cd mediaflow-proxy\n ```\n\n2. Install dependencies using Poetry:\n ```\n poetry install\n ```\n\n3. Set the `API_PASSWORD` environment variable in `.env`:\n ```\n echo \"API_PASSWORD=your_password\" > .env\n ```\n\n4. Run the FastAPI server:\n ```\n poetry run uvicorn mediaflow_proxy.main:app --host 0.0.0.0 --port 8888 --workers 4\n ```\n\n\n#### Build and Run Docker Image Locally\n\n1. Build the Docker image:\n ```\n docker build -t mediaflow-proxy .\n ```\n\n2. Run the Docker container:\n ```\n docker run -d -p 8888:8888 -e API_PASSWORD=your_password --restart unless-stopped --name mediaflow-proxy mediaflow-proxy\n ```\n\n### Option 2: Premium Hosted Service (ElfHosted)\n<div style=\"text-align: center;\">\n <img src=\"https://store.elfhosted.com/wp-content/uploads/2024/08/mediaflow-proxy.jpg\" alt=\"ElfHosted Logo\" width=\"200\" style=\"border-radius: 15px;\">\n</div>\nFor a hassle-free, high-performance deployment of MediaFlow Proxy, consider the premium hosted service through ElfHosted.\n\nTo purchase:\n1. Visit [https://store.elfhosted.com/product/mediaflow-proxy](https://store.elfhosted.com/product/mediaflow-proxy)\n2. Follow ElfHosted's setup instructions\n\nBenefits:\n- Instant setup and automatic updates\n- High performance and 24/7 availability\n- No server maintenance required\n\nIdeal for users who want a reliable, plug-and-play solution without the technical overhead of self-hosting.\n\n### Option 3: Hugging Face Space Deployment\n\n1. Visit the HF Space: [mhdzumair/mediaflow-proxy](https://huggingface.co/spaces/mhdzumair/mediaflow-proxy)\n2. Click on three dots on the right side of the page and select \"Duplicate Space\"\n3. Set the `API_PASSWORD` secret value & Set Visibility to \"Public\"\n4. Click on \"Duplicate Space\" to deploy the API\n\n## Usage\n\n### Endpoints\n\n1. `/proxy/hls/manifest.m3u8`: Proxify HLS streams\n2. `/proxy/stream`: Proxy generic http video streams\n3. `/proxy/mpd/manifest.m3u8`: Process MPD manifests\n4. `/proxy/mpd/playlist.m3u8`: Generate HLS playlists from MPD\n5. `/proxy/mpd/segment.mp4`: Process and decrypt media segments\n6. `/proxy/ip`: Get the public IP address of the MediaFlow Proxy server\n\nOnce the server is running, for more details on the available endpoints and their parameters, visit the Swagger UI at `http://localhost:8888/docs`.\n\n### Examples\n\n#### Proxy HTTPS Stream\n\n```bash\nmpv \"http://localhost:8888/proxy/stream?d=https://jsoncompare.org/LearningContainer/SampleFiles/Video/MP4/sample-mp4-file.mp4&api_password=your_password\"\n```\n\n#### Proxy HTTPS self-signed certificate Stream\n\nTo bypass SSL verification for a self-signed certificate stream, export the proxy route configuration:\n```bash\nPROXY_ROUTES='{\"https://self-signed.badssl.com\": {\"proxy_url\": null, \"verify_ssl\": false}}'\n```\n\n```bash\nmpv \"http://localhost:8888/proxy/stream?d=https://self-signed.badssl.com/&api_password=your_password\"\n```\n\n\n#### Proxy HLS Stream with Headers\n\n```bash\nmpv \"http://localhost:8888/proxy/hls/manifest.m3u8?d=https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8&h_referer=https://apple.com/&h_origin=https://apple.com&h_user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36&api_password=your_password\"\n```\n\n#### Live DASH Stream (Non-DRM Protected)\n\n```bash\nmpv -v \"http://localhost:8888/proxy/mpd/manifest.m3u8?d=https://livesim.dashif.org/livesim/chunkdur_1/ato_7/testpic4_8s/Manifest.mpd&api_password=your_password\"\n```\n\n#### VOD DASH Stream (DRM Protected)\n\n```bash\nmpv -v \"http://localhost:8888/proxy/mpd/manifest.m3u8?d=https://media.axprod.net/TestVectors/v7-MultiDRM-SingleKey/Manifest_1080p_ClearKey.mpd&key_id=nrQFDeRLSAKTLifXUIPiZg&key=FmY0xnWCPCNaSpRG-tUuTQ&api_password=your_password\"\n```\n\nNote: The `key` and `key_id` parameters are automatically processed if they're not in the correct format.\n\n### URL Encoding\n\nFor players like VLC that require properly encoded URLs, use the `encode_mediaflow_proxy_url` function:\n\n```python\nfrom mediaflow_proxy.utils.http_utils import encode_mediaflow_proxy_url\n\nencoded_url = encode_mediaflow_proxy_url(\n mediaflow_proxy_url=\"http://127.0.0.1:8888\",\n endpoint=\"/proxy/mpd/manifest.m3u8\",\n destination_url=\"https://media.axprod.net/TestVectors/v7-MultiDRM-SingleKey/Manifest_1080p_ClearKey.mpd\",\n query_params={\n \"key_id\": \"nrQFDeRLSAKTLifXUIPiZg\",\n \"key\": \"FmY0xnWCPCNaSpRG-tUuTQ\",\n \"api_password\": \"your_password\"\n },\n request_headers={\n \"referer\": \"https://media.axprod.net/\",\n \"origin\": \"https://media.axprod.net\",\n }\n)\n\nprint(encoded_url)\n\n# http://127.0.0.1:8888/proxy/mpd/manifest.m3u8?key_id=nrQFDeRLSAKTLifXUIPiZg&key=FmY0xnWCPCNaSpRG-tUuTQ&api_password=your_password&d=https%3A%2F%2Fmedia.axprod.net%2FTestVectors%2Fv7-MultiDRM-SingleKey%2FManifest_1080p_ClearKey.mpd&h_referer=https%3A%2F%2Fmedia.axprod.net%2F&h_origin=https%3A%2F%2Fmedia.axprod.net\n```\n\nThis will output a properly encoded URL that can be used with players like VLC.\n\n```bash\nvlc \"http://127.0.0.1:8888/proxy/mpd/manifest.m3u8?key_id=nrQFDeRLSAKTLifXUIPiZg&key=FmY0xnWCPCNaSpRG-tUuTQ&api_password=dedsec&d=https%3A%2F%2Fmedia.axprod.net%2FTestVectors%2Fv7-MultiDRM-SingleKey%2FManifest_1080p_ClearKey.mpd\"\n```\n\n### Generating Encrypted URLs\n\nTo generate an encrypted URL with optional IP restriction and expiration, Use the `/generate_encrypted_or_encoded_url` endpoint via swagger UI or programmatically as shown below:\n```python\nimport requests\n\nurl = \"http://localhost:8888/generate_encrypted_or_encoded_url\"\ndata = {\n \"mediaflow_proxy_url\": \"http://localhost:8888\",\n \"endpoint\": \"/proxy/mpd/manifest.m3u8\",\n \"destination_url\": \"https://media.axprod.net/TestVectors/v7-MultiDRM-SingleKey/Manifest_1080p_ClearKey.mpd\",\n \"query_params\": {\n \"key_id\": \"nrQFDeRLSAKTLifXUIPiZg\",\n \"key\": \"FmY0xnWCPCNaSpRG-tUuTQ\"\n },\n \"request_headers\": {\n \"referer\": \"https://media.axprod.net/\",\n \"origin\": \"https://media.axprod.net\",\n },\n \"expiration\": 3600, # URL will expire in 1 hour\n \"ip\": \"123.123.123.123\", # Optional: Restrict access to this IP\n \"api_password\": \"your_password\"\n}\n\nresponse = requests.post(url, json=data)\nencrypted_url = response.json()[\"encoded_url\"]\nprint(encrypted_url)\n```\n\nYou can then use the `encoded_url` in your player or application to access the media stream.\n\n\n### Using MediaFlow Proxy with Debrid Services and Stremio Addons\n\nMediaFlow Proxy can be particularly useful when working with Debrid services (like Real-Debrid, AllDebrid) and Stremio addons. The `/proxy/ip` endpoint allows you to retrieve the public IP address of the MediaFlow Proxy server, which is crucial for routing Debrid streams correctly.\n\nWhen a Stremio addon needs to create a video URL for a Debrid service, it typically needs to provide the user's public IP address. However, when routing the Debrid stream through MediaFlow Proxy, you should use the IP address of the MediaFlow Proxy server instead.\n\nHere's how to utilize MediaFlow Proxy in this scenario:\n\n1. If MediaFlow Proxy is accessible over the internet:\n - Use the `/proxy/ip` endpoint to get the MediaFlow Proxy server's public IP.\n - Use this IP when creating Debrid service URLs in your Stremio addon.\n\n2. If MediaFlow Proxy is set up locally:\n - Stremio addons can directly use the client's IP address.\n\n\n## Future Development\n\n- Add support for Widevine and PlayReady decryption\n\n## Acknowledgements and Inspirations\n\nMediaFlow Proxy was developed with inspiration from various projects and resources:\n\n- [Stremio Server](https://github.com/Stremio/stremio-server) for HLS Proxify implementation, which inspired our HLS M3u8 Manifest parsing and redirection proxify support.\n- [Comet Debrid proxy](https://github.com/g0ldyy/comet) for the idea of proxifying HTTPS video streams.\n- [mp4decrypt](https://www.bento4.com/developers/dash/encryption_and_drm/), [mp4box](https://wiki.gpac.io/xmlformats/Common-Encryption/), and [devine](https://github.com/devine-dl/devine) for insights on parsing MPD and decrypting Clear Key DRM protected content.\n- Test URLs were sourced from:\n - [OTTVerse MPEG-DASH MPD Examples](https://ottverse.com/free-mpeg-dash-mpd-manifest-example-test-urls/)\n - [OTTVerse HLS M3U8 Examples](https://ottverse.com/free-hls-m3u8-test-urls/)\n - [Bitmovin Stream Test](https://bitmovin.com/demos/stream-test)\n - [Bitmovin DRM Demo](https://bitmovin.com/demos/drm)\n - [DASH-IF Reference Player](http://reference.dashif.org/dash.js/nightly/samples/)\n- [HLS Protocol RFC](https://www.rfc-editor.org/rfc/rfc8216) for understanding the HLS protocol specifications.\n- Claude 3.5 Sonnet for code assistance and brainstorming.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\n[MIT License](LICENSE)\n\n\n## Disclaimer\n\nThis project is for educational purposes only. The developers of MediaFlow Proxy are not responsible for any misuse of this software. Please ensure that you have the necessary permissions to access and use the media streams you are proxying.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A high-performance proxy server for streaming media, supporting HTTP(S), HLS, and MPEG-DASH with real-time DRM decryption.",
"version": "1.9.4",
"project_urls": {
"Documentation": "https://github.com/mhdzumair/mediaflow-proxy#readme",
"Homepage": "https://github.com/mhdzumair/mediaflow-proxy",
"Repository": "https://github.com/mhdzumair/mediaflow-proxy"
},
"split_keywords": [
"proxy",
" media",
" streaming",
" hls",
" dash",
" drm"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4d1fbbe0f8414ce43f3d27bb62da57884bd2e914f7ad4b554141dd11d8e2b172",
"md5": "aab0a2e2a02d05c7dc93cdbf9332731d",
"sha256": "5ea719957d5ecdff5ff11eeec6892f413cae8d0336cb964508b3d7b536e56c1c"
},
"downloads": -1,
"filename": "mediaflow_proxy-1.9.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "aab0a2e2a02d05c7dc93cdbf9332731d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 155537,
"upload_time": "2024-11-17T15:40:51",
"upload_time_iso_8601": "2024-11-17T15:40:51.141410Z",
"url": "https://files.pythonhosted.org/packages/4d/1f/bbe0f8414ce43f3d27bb62da57884bd2e914f7ad4b554141dd11d8e2b172/mediaflow_proxy-1.9.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b187ed7ac9973e250e11127c8d750698c13f4fa8850d27a296a02ba0687d48ba",
"md5": "7f2a470f08a54017f2bb92f3e9b2e216",
"sha256": "e46b6e6b6fa110c30b86ca827ee3ead3badbe38de2f5e4b995a86bc1b53f3191"
},
"downloads": -1,
"filename": "mediaflow_proxy-1.9.4.tar.gz",
"has_sig": false,
"md5_digest": "7f2a470f08a54017f2bb92f3e9b2e216",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 143938,
"upload_time": "2024-11-17T15:40:52",
"upload_time_iso_8601": "2024-11-17T15:40:52.723430Z",
"url": "https://files.pythonhosted.org/packages/b1/87/ed7ac9973e250e11127c8d750698c13f4fa8850d27a296a02ba0687d48ba/mediaflow_proxy-1.9.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-17 15:40:52",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mhdzumair",
"github_project": "mediaflow-proxy",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "mediaflow-proxy"
}