Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand HLS segment name metadata #4135

Merged
merged 4 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ New:
one stream is encoded.
- Allow trailing commas in record definition (#3300).
- Add `metadata.getter.source.float` (#3356).
- BREAKING: Added `duration` and `ticks` to metadata available when computing HLS segment names (#4135)
- Added optional `main_playlist_writer` to `output.file.hls` and
derivated operator (#3484)
- Added `is_nan`, `is_infinite`, `ceil`, `floor`, `sign` and `round` (#3407)
Expand Down
61 changes: 27 additions & 34 deletions doc/content/liq/output.file.hls.liq
Original file line number Diff line number Diff line change
@@ -1,44 +1,37 @@
s = mksafe(playlist("playlist"))

aac_lofi = %ffmpeg(format="mpegts",
%audio(
codec="aac",
channels=2,
ar=44100
))
aac_lofi =
%ffmpeg(format = "mpegts", %audio(codec = "aac", channels = 2, ar = 44100))

aac_midfi = %ffmpeg(format="mpegts",
%audio(
codec="aac",
channels=2,
ar=44100,
b="96k"
))
aac_midfi =
%ffmpeg(
format = "mpegts",
%audio(codec = "aac", channels = 2, ar = 44100, b = "96k")
)

aac_hifi = %ffmpeg(format="mpegts",
%audio(
codec="aac",
channels=2,
ar=44100,
b="192k"
))
aac_hifi =
%ffmpeg(
format = "mpegts",
%audio(codec = "aac", channels = 2, ar = 44100, b = "192k")
)

streams = [("aac_lofi",aac_lofi),
("aac_midfi", aac_midfi),
("aac_hifi", aac_hifi)]
streams =
[("aac_lofi", aac_lofi), ("aac_midfi", aac_midfi), ("aac_hifi", aac_hifi)]

def segment_name(~position,~extname,stream_name) =
def segment_name(metadata) =
timestamp = int_of_float(time())
duration = 2
let {stream_name, duration, position, extname} = metadata
"#{stream_name}_#{duration}_#{timestamp}_#{position}.#{extname}"
end

output.file.hls(playlist="live.m3u8",
segment_duration=2.0,
segments=5,
segments_overhead=5,
segment_name=segment_name,
persist_at="/tmp/path/to/state.config",
"/tmp/path/to/hls/directory",
streams,
s)
output.file.hls(
playlist="live.m3u8",
segment_duration=2.0,
segments=5,
segments_overhead=5,
segment_name=segment_name,
persist_at="/tmp/path/to/state.config",
"/tmp/path/to/hls/directory",
streams,
s
)
13 changes: 13 additions & 0 deletions doc/content/migrating.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,19 @@ Known incompatibilities include:

- `(?P<name>pattern)` for named captures is not supported. `(?<name>pattern)` should be used instead.

### `segment_name` in HLS outputs

To make segment name more flexible, `duration` (segment duration in seconds) and `ticks` (segment exact duration in liquidsoap's main ticks) have been added
to the data available when calling `segment_name`.

To prevent any further breakage of this function, its arguments have been changed to a single record containing all the available attributes:

```liquidsoap
def segment_name(metadata) =
"#{metadata.stream_name}_#{metadata.position}.#{metadata.extname}"
end
```

### `on_air` metadata

Request `on_air` and `on_air_timestamp` metadata are deprecated. These values were never reliable. They are set at the request level when `request.dynamic`
Expand Down
Loading
Loading