diff options
author | Karthick Jeyapal <kjeyapal@akamai.com> | 2018-09-28 12:55:54 +0530 |
---|---|---|
committer | Marton Balint <cus@passwd.hu> | 2018-09-30 21:09:12 +0200 |
commit | c0ee4e0ac2c46bb4904ceec12b7dfa480517e7bf (patch) | |
tree | 5eff33b0faaac4074d3cb615d044cec8b0ea718b /libavdevice/decklink_dec.cpp | |
parent | 449b1dcd7d52b33b148fae95de176b7344bf959d (diff) | |
download | ffmpeg-c0ee4e0ac2c46bb4904ceec12b7dfa480517e7bf.tar.gz |
avdevice/decklink_dec: add option to align capture start time
This option is useful for maintaining input synchronization across N
different hardware devices deployed for 'N-way' redundancy.
The system time of different hardware devices should be synchronized
with protocols such as NTP or PTP, before using this option.
Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavdevice/decklink_dec.cpp')
-rw-r--r-- | libavdevice/decklink_dec.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp index 7fabef231c..deb8f787ee 100644 --- a/libavdevice/decklink_dec.cpp +++ b/libavdevice/decklink_dec.cpp @@ -703,6 +703,16 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( return S_OK; } + // Drop the frames till system's timestamp aligns with the configured value. + if (0 == ctx->frameCount && cctx->timestamp_align) { + AVRational remainder = av_make_q(av_gettime() % cctx->timestamp_align, 1000000); + AVRational frame_duration = av_inv_q(ctx->video_st->r_frame_rate); + if (av_cmp_q(remainder, frame_duration) > 0) { + ++ctx->dropped; + return S_OK; + } + } + ctx->frameCount++; if (ctx->audio_pts_source == PTS_SRC_WALLCLOCK || ctx->video_pts_source == PTS_SRC_WALLCLOCK) wallclock = av_gettime_relative(); |