Spaces:
Running
Running
Remove #EXT-X-PROGRAM-DATE-TIME tags, live stream delay due to playback not supported in ExoPlayer
Browse files- README.md +0 -1
- mediaflow_proxy/configs.py +0 -1
- mediaflow_proxy/mpd_processor.py +0 -9
README.md
CHANGED
@@ -41,7 +41,6 @@ Set the following environment variables:
|
|
41 |
|
42 |
- `API_PASSWORD`: Required. Protects against unauthorized access and API network abuses.
|
43 |
- `PROXY_URL`: Optional. HTTP/HTTPS/SOCKS5 proxy URL for forwarding network requests.
|
44 |
-
- `MPD_LIVE_STREAM_DELAY`: Optional. Delay in seconds for live DASH streams. This is useful to prevent buffering issues with live streams. Default is `30` seconds.
|
45 |
|
46 |
## Installation
|
47 |
|
|
|
41 |
|
42 |
- `API_PASSWORD`: Required. Protects against unauthorized access and API network abuses.
|
43 |
- `PROXY_URL`: Optional. HTTP/HTTPS/SOCKS5 proxy URL for forwarding network requests.
|
|
|
44 |
|
45 |
## Installation
|
46 |
|
mediaflow_proxy/configs.py
CHANGED
@@ -4,7 +4,6 @@ from pydantic_settings import BaseSettings
|
|
4 |
class Settings(BaseSettings):
|
5 |
api_password: str # The password for accessing the API endpoints.
|
6 |
proxy_url: str | None = None # The URL of the proxy server to route requests through.
|
7 |
-
mpd_live_stream_delay: int = 10 # The delay in seconds for live MPD streams.
|
8 |
|
9 |
class Config:
|
10 |
env_file = ".env"
|
|
|
4 |
class Settings(BaseSettings):
|
5 |
api_password: str # The password for accessing the API endpoints.
|
6 |
proxy_url: str | None = None # The URL of the proxy server to route requests through.
|
|
|
7 |
|
8 |
class Config:
|
9 |
env_file = ".env"
|
mediaflow_proxy/mpd_processor.py
CHANGED
@@ -1,11 +1,9 @@
|
|
1 |
import logging
|
2 |
import math
|
3 |
import time
|
4 |
-
from datetime import datetime, timezone, timedelta
|
5 |
|
6 |
from fastapi import Request, Response, HTTPException
|
7 |
|
8 |
-
from mediaflow_proxy.configs import settings
|
9 |
from mediaflow_proxy.drm.decrypter import decrypt_segment
|
10 |
from mediaflow_proxy.utils.crypto_utils import encryption_handler
|
11 |
from mediaflow_proxy.utils.http_utils import encode_mediaflow_proxy_url, get_original_scheme, ProxyRequestHeaders
|
@@ -162,9 +160,6 @@ def build_hls_playlist(mpd_dict: dict, profiles: list[dict], request: Request) -
|
|
162 |
hls = ["#EXTM3U", "#EXT-X-VERSION:6"]
|
163 |
|
164 |
added_segments = 0
|
165 |
-
current_time = datetime.now(timezone.utc)
|
166 |
-
live_stream_delay = timedelta(seconds=settings.mpd_live_stream_delay)
|
167 |
-
target_end_time = current_time - live_stream_delay
|
168 |
|
169 |
proxy_url = request.url_for("segment_endpoint")
|
170 |
proxy_url = str(proxy_url.replace(scheme=get_original_scheme(request)))
|
@@ -199,10 +194,6 @@ def build_hls_playlist(mpd_dict: dict, profiles: list[dict], request: Request) -
|
|
199 |
has_encrypted = query_params.pop("has_encrypted", False)
|
200 |
|
201 |
for segment in segments:
|
202 |
-
if mpd_dict["isLive"]:
|
203 |
-
if segment["end_time"] > target_end_time:
|
204 |
-
continue
|
205 |
-
hls.append(f"#EXT-X-PROGRAM-DATE-TIME:{segment['program_date_time']}")
|
206 |
hls.append(f'#EXTINF:{segment["extinf"]:.3f},')
|
207 |
query_params.update(
|
208 |
{"init_url": init_url, "segment_url": segment["media"], "mime_type": profile["mimeType"]}
|
|
|
1 |
import logging
|
2 |
import math
|
3 |
import time
|
|
|
4 |
|
5 |
from fastapi import Request, Response, HTTPException
|
6 |
|
|
|
7 |
from mediaflow_proxy.drm.decrypter import decrypt_segment
|
8 |
from mediaflow_proxy.utils.crypto_utils import encryption_handler
|
9 |
from mediaflow_proxy.utils.http_utils import encode_mediaflow_proxy_url, get_original_scheme, ProxyRequestHeaders
|
|
|
160 |
hls = ["#EXTM3U", "#EXT-X-VERSION:6"]
|
161 |
|
162 |
added_segments = 0
|
|
|
|
|
|
|
163 |
|
164 |
proxy_url = request.url_for("segment_endpoint")
|
165 |
proxy_url = str(proxy_url.replace(scheme=get_original_scheme(request)))
|
|
|
194 |
has_encrypted = query_params.pop("has_encrypted", False)
|
195 |
|
196 |
for segment in segments:
|
|
|
|
|
|
|
|
|
197 |
hls.append(f'#EXTINF:{segment["extinf"]:.3f},')
|
198 |
query_params.update(
|
199 |
{"init_url": init_url, "segment_url": segment["media"], "mime_type": profile["mimeType"]}
|