Skip to content

Commit

Permalink
Exclude mp4.
Browse files Browse the repository at this point in the history
  • Loading branch information
toots committed Jun 24, 2023
1 parent fb3e49f commit 0abe0e0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
3 changes: 2 additions & 1 deletion doc/content/hls_output.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ not recommended for listener-facing setup but can be useful to sync up with a ca

HLS outputs supports metadata in two ways:

- Through a `timed_id3` metadata logical stream with `mpegts` and `mp4` formats
- Through a `timed_id3` metadata logical stream with the `mpegts` format.
- Through regular ID3 frames, as requested by the [HLS specifications](https://datatracker.ietf.org/doc/html/rfc8216#section-3.4) for `adts`, `mp3`, `ac3` and `eac3` formats.
- There is currently no support for in-stream metadata for the `mp4` format.

Metadata parameters are passed through the record methods of the streams' encoders. Here's an example

Expand Down
4 changes: 2 additions & 2 deletions src/core/encoder/encoders/ffmpeg_encoder_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ let encoder ~pos ~mk_streams ffmpeg meta =
let init ?id3_enabled ?id3_version () =
let encoder = !encoder in
match Option.map Av.Format.get_output_name encoder.format with
| Some "mpegts" | Some "mp4" ->
if id3_enabled = Some true then (
| Some "mpegts" ->
if id3_enabled <> Some false then (
let id3_version = Option.value ~default:3 id3_version in
let time_base = Ffmpeg_utils.liq_audio_sample_time_base () in
let stream =
Expand Down
28 changes: 21 additions & 7 deletions tests/streams/hls_id3v2.liq
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,31 @@ output.file.hls(
tmp_dir,
[
("aac", %ffmpeg(format="adts",%audio(codec="aac")).{id3_version = 3}),
("ts_with_meta", %ffmpeg(format="mpegts",%audio(codec="aac")).{id3 = true, id3_version = 4}),
("ts", %ffmpeg(format="mpegts",%audio(codec="aac")))
("ts_with_meta", %ffmpeg(format="mpegts",%audio(codec="aac")).{id3_version = 4}),
("ts", %ffmpeg(format="mpegts",%audio(codec="aac")).{ id3=false }),
("mp4", %ffmpeg(format="mp4",frag_duration=10,movflags="+dash+skip_sidx+skip_trailer+frag_custom",%audio(codec="aac")))
],
s
)

to_check = ref({
aac = null(),
ts_with_meta = null(),
ts = null()
ts = null(),
mp4 = null()
})

def check_done() =
let { aac, ts_with_meta, ts } = to_check()
let { aac, ts_with_meta, ts, mp4 } = to_check()

if null.defined(ts) then test.fail("ts shouldn't have metadata!") end
if null.defined(mp4) then test.fail("mp4 should have metadata but it's not supported by the demuxer yet.") end

if null.defined(aac) and null.defined(ts_with_meta) then
aac = null.get(aac)
ts_with_meta = null.get(ts_with_meta)
if aac["title"] == "test title" and ts_with_meta["title"] == "test title" and
aac["album"] == "foolol" and ts_with_meta["album"] == "foolol" then
if aac["title"] == "test title" and aac["album"] == "foolol" and
ts_with_meta["title"] == "test title" and ts_with_meta["album"] == "foolol" then
test.pass()
end
end
Expand Down Expand Up @@ -77,4 +80,15 @@ end)

output.dummy(fallible=true, ts)

clock.assign_new(sync="none",[s, aac, ts_with_meta, ts])
mp4 = input.hls("#{tmp_dir}/mp4.m3u8")

mp4 = source.on_metadata(mp4, fun (m) -> begin
if m["title"] != "" then
to_check := to_check().{ mp4 = m }
end
check_done()
end)

output.dummy(fallible=true, mp4)

clock.assign_new(sync="none",[s, aac, ts_with_meta, ts, mp4])

0 comments on commit 0abe0e0

Please sign in to comment.