Skip to content

Commit

Permalink
fix: avoid Found duplicated MOOV Atom. Skipped it
Browse files Browse the repository at this point in the history
  • Loading branch information
acgnhiki committed Jun 21, 2024
1 parent fff5994 commit 772eb5e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/blrec/hls/operators/playlist_dumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
from copy import deepcopy
from decimal import Decimal
from pathlib import PurePath
from typing import Optional, Tuple, Union
from typing import Optional, Tuple, Union, cast

import m3u8
from loguru import logger
from m3u8.model import InitializationSection
from reactivex import Observable, Subject, abc
from reactivex.disposable import CompositeDisposable, Disposable, SerialDisposable

Expand Down Expand Up @@ -139,7 +140,9 @@ def _make_segment(
) -> m3u8.Segment:
seg = deepcopy(segment)
if init_section := getattr(seg, 'init_section', None):
init_section = cast(InitializationSection, init_section)
init_section.uri = uri
init_section.base_uri = ''
init_section.byterange = init_section_byterange
seg.uri = uri
seg.byterange = segment_byterange
Expand Down
10 changes: 10 additions & 0 deletions src/blrec/hls/operators/segment_dumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ def _write_data(self, item: Union[InitSectionData, SegmentData]) -> Tuple[int, i
def _update_filesize(self, size: int) -> None:
self._filesize += size

def _is_redundant(
self, prev_init_item: Optional[InitSectionData], curr_init_item: InitSectionData
) -> bool:
return (
prev_init_item is not None
and curr_init_item.payload == prev_init_item.payload
)

def _must_split_file(
self, prev_init_item: Optional[InitSectionData], curr_init_item: InitSectionData
) -> bool:
Expand Down Expand Up @@ -141,6 +149,8 @@ def on_next(item: Union[InitSectionData, SegmentData]) -> None:
split_file = False

if isinstance(item, InitSectionData):
if self._is_redundant(last_init_item, item):
return
split_file = self._must_split_file(last_init_item, item)
last_init_item = item

Expand Down
1 change: 0 additions & 1 deletion src/blrec/hls/operators/segment_fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def on_next(seg: m3u8.Segment) -> None:
(
last_segment is None
or seg.init_section != last_segment.init_section
or seg.discontinuity
)
):
url = seg.init_section.absolute_uri
Expand Down

0 comments on commit 772eb5e

Please sign in to comment.