From 6d4be8620c810c0f07c2703fa14d997b87493be5 Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Wed, 17 May 2023 01:22:59 +0100 Subject: [PATCH] Only write segment data if the tfhd fix was necessary in DASH --- devine/core/manifests/dash.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/devine/core/manifests/dash.py b/devine/core/manifests/dash.py index acced29..7e3031a 100644 --- a/devine/core/manifests/dash.py +++ b/devine/core/manifests/dash.py @@ -450,13 +450,14 @@ class DASH: if isinstance(track, Audio): with open(segment_save_path, "rb+") as f: segment_data = f.read() - segment_data = re.sub( + fixed_segment_data = re.sub( b"(tfhd\x00\x02\x00\x1a\x00\x00\x00\x01\x00\x00\x00)\x02", b"\\g<1>\x01", segment_data ) - f.seek(0) - f.write(segment_data) + if fixed_segment_data != segment_data: + f.seek(0) + f.write(fixed_segment_data) return data_size