forked from kenzuya/unshackle
fix(tracks): mark AC-4 Atmos from the HLS ATMOS channels identifier and carry atmos without JOC through signature, export and remote
This commit is contained in:
@@ -116,7 +116,7 @@ def audio_token(track: Audio) -> str:
|
||||
channels = track.channels
|
||||
if isinstance(channels, float):
|
||||
channels = f"{channels:.1f}"
|
||||
return f"{codec}{channels or ''}{'atmos' if track.joc else ''}"
|
||||
return f"{codec}{channels or ''}{'atmos' if track.atmos else ''}"
|
||||
|
||||
|
||||
def quality_parts(tracks: Iterable[AnyTrack]) -> list[str]:
|
||||
@@ -137,7 +137,7 @@ def quality_parts(tracks: Iterable[AnyTrack]) -> list[str]:
|
||||
key=lambda a: (
|
||||
audio_order.index(a.codec) if a.codec else len(audio_order),
|
||||
-Audio.channel_total(a.channels) if a.channels else 0,
|
||||
not a.joc,
|
||||
not a.atmos,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -240,7 +240,7 @@ class ExportWriter:
|
||||
if t.stereo:
|
||||
row["stereo"] = True
|
||||
elif isinstance(t, Audio):
|
||||
row.update(channels=str(t.channels) if t.channels else "", atmos=bool(t.joc), descriptive=t.descriptive)
|
||||
row.update(channels=str(t.channels) if t.channels else "", atmos=t.atmos, descriptive=t.descriptive)
|
||||
elif isinstance(t, Subtitle):
|
||||
row.update(sdh=t.sdh, forced=t.forced, cc=t.cc)
|
||||
if t.descriptor == Video.Descriptor.URL:
|
||||
|
||||
@@ -1537,7 +1537,13 @@ class DASH:
|
||||
|
||||
@staticmethod
|
||||
def get_ddp_complexity_index(adaptation_set: Element, representation: Element | None) -> int | None:
|
||||
"""Get the DD+ Complexity Index (if any) from the AdaptationSet or Representation."""
|
||||
"""
|
||||
Get the DD+ Complexity Index (if any) from the AdaptationSet or Representation.
|
||||
|
||||
An MPD has no Atmos signal for AC-4: ETSI TS 103 190-2 E.13 and G.3.1 give no Atmos meaning to the codecs
|
||||
string or virtualized_content, and the Dolby AC-4 DASH spec (Online Delivery Kit 1.5) allows immersive
|
||||
stereo for any audio.
|
||||
"""
|
||||
return next(
|
||||
(
|
||||
int(x.get("value"))
|
||||
|
||||
@@ -207,6 +207,7 @@ class HLS:
|
||||
All Track objects' URL will be to another M3U(8) document. However, these documents
|
||||
will be Invariant Playlists and contain the list of segments URIs among other metadata.
|
||||
A variant or a media entry that the master lists twice with the same attributes gets one track.
|
||||
A CHANNELS coding identifier ATMOS marks Atmos (Dolby AC-4 HLS spec, Online Delivery Kit 1.5: "2/IMSA,ATMOS").
|
||||
"""
|
||||
session_keys = list(self.manifest.session_keys or [])
|
||||
if not session_keys:
|
||||
@@ -332,6 +333,7 @@ class HLS:
|
||||
entries.add(entry)
|
||||
|
||||
joc = 0
|
||||
atmos = False
|
||||
track_type: type[Audio] | type[Subtitle]
|
||||
if media.type == "AUDIO":
|
||||
track_type = Audio
|
||||
@@ -343,7 +345,9 @@ class HLS:
|
||||
if media.channels:
|
||||
# the channel count, then /-separated coding (JOC) and usage identifiers (RFC 8216bis)
|
||||
count, *identifiers = media.channels.split("/")
|
||||
if identifiers and "JOC" in identifiers[0].split(","):
|
||||
coding = identifiers[0].split(",") if identifiers else []
|
||||
atmos = "ATMOS" in coding
|
||||
if "JOC" in coding:
|
||||
joc = int(count)
|
||||
media.channels = "5.1"
|
||||
else:
|
||||
@@ -379,6 +383,7 @@ class HLS:
|
||||
bitrate=0, # TODO: M3U doesn't seem to state bitrate?
|
||||
channels=media.channels,
|
||||
joc=joc,
|
||||
extra={"atmos": True} if atmos else None,
|
||||
descriptive="public.accessibility.describes-video" in (media.characteristics or ""),
|
||||
**resolution,
|
||||
)
|
||||
|
||||
@@ -416,6 +416,7 @@ class Tracks:
|
||||
track.codec,
|
||||
track.channels,
|
||||
track.joc,
|
||||
track.atmos,
|
||||
track.descriptive,
|
||||
track.bitrate,
|
||||
track.bit_depth,
|
||||
|
||||
@@ -824,14 +824,13 @@ def deserialize_video(data: dict[str, Any]) -> Video:
|
||||
|
||||
def deserialize_audio(data: dict[str, Any]) -> Audio:
|
||||
"""An audio track from its REST form."""
|
||||
joc = data.get("joc")
|
||||
return Audio(
|
||||
**rest_track_kwargs(data),
|
||||
codec=enum_get(Audio.Codec, data.get("codec")),
|
||||
bitrate=deserialize_bitrate(data),
|
||||
channels=data.get("channels"),
|
||||
joc=joc,
|
||||
extra={"atmos": True} if joc is None and data.get("atmos") else None,
|
||||
joc=data.get("joc"),
|
||||
extra={"atmos": True} if data.get("atmos") else None,
|
||||
descriptive=data.get("descriptive", False),
|
||||
bit_depth=data.get("bit_depth"),
|
||||
sample_rate=data.get("sample_rate"),
|
||||
@@ -919,6 +918,7 @@ def track_to_dict(track: Track) -> dict[str, Any]:
|
||||
"bitrate": track.bitrate,
|
||||
"channels": track.channels,
|
||||
"joc": track.joc,
|
||||
"atmos": track.atmos,
|
||||
"descriptive": track.descriptive,
|
||||
"bit_depth": track.bit_depth,
|
||||
"sample_rate": track.sample_rate,
|
||||
@@ -969,6 +969,7 @@ def track_from_dict(data: dict[str, Any]) -> Video | Audio | Subtitle:
|
||||
bitrate=data.get("bitrate"),
|
||||
channels=data.get("channels"),
|
||||
joc=data.get("joc"),
|
||||
extra={"atmos": True} if data.get("atmos") else None,
|
||||
descriptive=data.get("descriptive", False),
|
||||
bit_depth=data.get("bit_depth"),
|
||||
sample_rate=data.get("sample_rate"),
|
||||
|
||||
Reference in New Issue
Block a user