Skip to content

Commit

Permalink
FFmpeg filters: keep value in TS unit, move time-based values to _time
Browse files Browse the repository at this point in the history
postfixed entries.
Autocue: sort frames by pts.
  • Loading branch information
toots committed Oct 8, 2024
1 parent f2117c1 commit 65678e5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/core/io/ffmpeg_filter_io.ml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,10 @@ class virtual ['a] input_base ~name ~pass_metadata ~self_sync ~is_ready ~pull
(fun result (label, fn) ->
match fn frame with
| None -> result
| Some v -> ("lavfi.liq." ^ label, get_time v) :: result)
| Some v ->
("lavfi.liq." ^ label, Int64.to_string v)
:: ("lavfi.liq." ^ label ^ "_time", get_time v)
:: result)
[]
[
("pts", Avutil.Frame.pts);
Expand Down
20 changes: 16 additions & 4 deletions src/libs/autocue.liq
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,17 @@ def autocue.internal.ebur128(~ratio=50., ~timeout=10., filename) =
s = source.on_metadata(s, fun (m) -> frames := [...frames(), m])
source.drop(ratio=ratio, s)

frames()
list.sort(
fun (m, m') ->
begin
pos =
float_of_string(list.assoc(default="0.", "lavfi.liq.pts_time", m))
pos' =
float_of_string(list.assoc(default="0.", "lavfi.liq.pts_time", m'))
if pos < pos' then -1 elsif pos < pos' then 1 else 0 end
end,
frames()
)
end
%else
ignore(ratio)
Expand Down Expand Up @@ -387,7 +397,7 @@ def autocue.internal.implementation(
# Get current frame loudness level and timestamp
db_level = list.assoc(default="nan", string("lavfi.r128.M"), frame)
current_ts :=
float_of_string(list.assoc(default="0.", "lavfi.liq.pts", frame))
float_of_string(list.assoc(default="0.", "lavfi.liq.pts_time", frame))

# Process only valid level values
if
Expand Down Expand Up @@ -708,8 +718,10 @@ def autocue.internal.implementation(
# Get very last frame for precise track duration
frame = list.last(frames)
duration =
float_of_string(list.assoc(default="0.", "lavfi.liq.pts", frame)) +
float_of_string(list.assoc(default="0.", "lavfi.liq.duration", frame))
float_of_string(list.assoc(default="0.", "lavfi.liq.pts_time", frame)) +
float_of_string(
list.assoc(default="0.", "lavfi.liq.duration_time", frame)
)

# Finalize cue/cross/fade values now...
if cue_out() == 0. then cue_out := duration end
Expand Down

0 comments on commit 65678e5

Please sign in to comment.