Skip to content

Commit

Permalink
upipe_avfilter: update flow def latency
Browse files Browse the repository at this point in the history
  • Loading branch information
nto authored and cmassiot committed Feb 13, 2025
1 parent 59c3e23 commit 18f2c5a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/upipe-av/upipe_avfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -2230,6 +2230,26 @@ static void upipe_avfilt_output_frame(struct upipe *upipe,
upipe_throw_error(upipe, UBASE_ERR_ALLOC);
return;
}

uint64_t latency = 0;
if (frame->pts != AV_NOPTS_VALUE) {
AVRational time_base = av_buffersink_get_time_base(
upipe_avfilt->buffersink_ctx);
uint64_t pts = av_rescale_q(frame->pts, time_base,
av_make_q(1, UCLOCK_FREQ));
uint64_t input_pts;
if (ubase_check(uref_clock_get_pts_prog(
upipe_avfilt->uref, &input_pts)) &&
input_pts >= pts) {
latency = input_pts - pts;
upipe_notice_va(upipe, "latency: %" PRIu64 " ms",
1000 * latency / UCLOCK_FREQ);
}
}
uint64_t input_latency = 0;
uref_clock_get_latency(upipe_avfilt->flow_def_input, &input_latency);
uref_clock_set_latency(flow_def, input_latency + latency);

upipe_avfilt_store_flow_def(upipe, flow_def);
}

Expand Down

0 comments on commit 18f2c5a

Please sign in to comment.