fix(tracks): keep segment resume across an hls merge failure and a locked partial on windows

This commit is contained in:
imSp4rky
2026-11-28 20:26:40 -07:00
parent 37357673fe
commit 74fa29b6f1
5 changed files with 212 additions and 38 deletions
+3 -1
View File
@@ -816,7 +816,6 @@ class HLS:
rolling_merge=use_rolling_merge,
drm=session_drm,
aes128=any(key and key.method == "AES-128" for key in (master.keys or [])),
merge_rewrites=True,
),
)
segment_save_dir.mkdir(exist_ok=True)
@@ -899,6 +898,7 @@ class HLS:
delete: Delete each source file after this function merges it.
include_map_data: Whether to include the init map data.
"""
store.rewriting()
prepend = include_map_data and map_data and map_data[1]
if len(via) == 1 and not prepend and delete:
try:
@@ -974,6 +974,7 @@ class HLS:
# AES segments must be decrypted individually before merging: each segment
# likely carries its own 16-byte padding
key_obj = encryption_data[0]
store.rewriting()
# AES-128 with no explicit IV: each segment's IV is its media sequence
# number (RFC 8216 §5.2). Without this the engine used a zero IV and the
# output decrypted to garbage.
@@ -1040,6 +1041,7 @@ class HLS:
.encode("utf8")
)
if segment_data != original_data:
store.rewriting()
segment_file_path.write_bytes(segment_data)
if segment.discontinuity and i != 0: