History

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.

Karthick Jeyapal committed 8 years ago

Commit c0ee4e01 parent 449b1dc5 files · +27 −1Browse files

Showing the changes to libavdevice (4 of 5 files). Show all

Unified · Split

4 files
  1. libavdevice/decklink_common_c.h +1 −0
  2. libavdevice/decklink_dec.cpp +10 −0
  3. libavdevice/decklink_dec_c.c +1 −0
  4. libavdevice/version.h +1 −1
libavdevice/decklink_common_c.h+1−0
@@ -56,6 +56,7 @@ struct decklink_cctx { · 55 unmodified lines
5656 int raw_format;
5757 int64_t queue_size;
5858 int copyts;
59+ int64_t timestamp_align;
5960 };
6061
6162 #endif /* AVDEVICE_DECKLINK_COMMON_C_H */
libavdevice/decklink_dec.cpp+10−0
@@ -703,6 +703,16 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( · 702 unmodified lines
703703 return S_OK;
704704 }
705705
706+ // Drop the frames till system's timestamp aligns with the configured value.
707+ if (0 == ctx->frameCount && cctx->timestamp_align) {
708+ AVRational remainder = av_make_q(av_gettime() % cctx->timestamp_align, 1000000);
709+ AVRational frame_duration = av_inv_q(ctx->video_st->r_frame_rate);
710+ if (av_cmp_q(remainder, frame_duration) > 0) {
711+ ++ctx->dropped;
712+ return S_OK;
713+ }
714+ }
715+
706716 ctx->frameCount++;
707717 if (ctx->audio_pts_source == PTS_SRC_WALLCLOCK || ctx->video_pts_source == PTS_SRC_WALLCLOCK)
708718 wallclock = av_gettime_relative();
libavdevice/decklink_dec_c.c+1−0
@@ -84,6 +84,7 @@ static const AVOption options[] = { · 83 unmodified lines
8484 { "queue_size", "input queue buffer size", OFFSET(queue_size), AV_OPT_TYPE_INT64, { .i64 = (1024 * 1024 * 1024)}, 0, INT64_MAX, DEC },
8585 { "audio_depth", "audio bitdepth (16 or 32)", OFFSET(audio_depth), AV_OPT_TYPE_INT, { .i64 = 16}, 16, 32, DEC },
8686 { "decklink_copyts", "copy timestamps, do not remove the initial offset", OFFSET(copyts), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, DEC },
87+ { "timestamp_align", "capture start time alignment (in seconds)", OFFSET(timestamp_align), AV_OPT_TYPE_DURATION, { .i64 = 0 }, 0, INT_MAX, DEC },
8788 { NULL },
8889 };
8990
libavdevice/version.h+1−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
2929
3030 #define LIBAVDEVICE_VERSION_MAJOR 58
3131 #define LIBAVDEVICE_VERSION_MINOR 4
32−#define LIBAVDEVICE_VERSION_MICRO 104
32+#define LIBAVDEVICE_VERSION_MICRO 105
3333
3434 #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
3535 LIBAVDEVICE_VERSION_MINOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t