Synchronous Record/Playback with Decklink Quad 2 using SDK

Ask software engineering and SDK questions for developers working on Mac OS X, Windows or Linux.
  • Author
  • Message
Offline

Steffen Pätzold

  • Posts: 21
  • Joined: Mon Mar 30, 2015 10:35 am
  • Location: Leipzig, Germany

Synchronous Record/Playback with Decklink Quad 2 using SDK

PostThu Sep 28, 2017 7:27 am

We are using a Decklink Quad 2 to record and playback multiple videofeeds.
All videofeeds are synced and the reference signal is also attached.

When recording, the hardware timestamp, aquired with IDeckLinkVideoInputFrame::GetHardwareReferenceTimestamp is still varying a little.
Is there a general rule to be sure that frames are synchronous?
Is it possible to start grabbing on different devices at the same hardwaretime?

At playback it is basically the same issue. We are using scheduled playback. Is it possible to schedule frames on different decklink devices at exactly the same hardwaretime?
Offline

Cameron Nichols

Blackmagic Design

  • Posts: 442
  • Joined: Mon Sep 04, 2017 4:05 am

Re: Synchronous Record/Playback with Decklink Quad 2 using S

PostTue Oct 10, 2017 5:16 am

Hi Steffen,

It is expected that the frameTime returned by GetHardwareReferenceTimestamp will vary. The DeckLink Quad 2 inputs are considered independent of one another, so there will be differences in hardware cycles when IDeckLinkInputCallback::VideoInputFrameArrived callback occurs for each input.

Currently there is no way of synchronising the callbacks to capture at the same hardware time, so some additional setup and coding is required for the application to perform synchronisation (for instance, one solution could be to use timecode).

Kind Regards
Cameron Nichols
Offline

Steffen Pätzold

  • Posts: 21
  • Joined: Mon Mar 30, 2015 10:35 am
  • Location: Leipzig, Germany

Re: Synchronous Record/Playback with Decklink Quad 2 using S

PostTue Oct 10, 2017 9:03 am

Hi Cameron,

thanks for the information. In the meantime i already implemented a synchronisation method based on the hardware timestamps from each device in combination with the windows api QueryPerformanceCounter.

Timecode is not an option for us because not all video feeds contain a timecode.

By evaluating the hardware timestamps deliverd by the decklink devices i noticed (on various systems) that the GetHardwareReferenceTimestamp funtion returns a frame duration like 1000 (e.g 1080p50 with timescale 50000). But when evaluating the returned hardware timestamp after a few thousand frames the internal clock seems to tick with 1000.005.
Does this means the clock is just a little inacurate or is the device dropping a frame after about 4000 frames captured?
This may sounds pedantic ;) , but when working with fill/key signals a few hours in live production every frame is important.

Regards
Steffen
Offline

Cameron Nichols

Blackmagic Design

  • Posts: 442
  • Joined: Mon Sep 04, 2017 4:05 am

Re: Synchronous Record/Playback with Decklink Quad 2 using S

PostWed Oct 11, 2017 1:19 am

Hi Steffen,

There could be several causes for this - SDI timing synchronisation; inaccuracy of your system clock; etc

To check that it is not a dropped frame, you should check with IDeckLinkVideoInputFrame::GetStreamTime method [1], which should return an incremental frame time (in multiples of 1000).

Regards
Cameron

Refs
[1] DeckLink SDK Manual - 2.5.11.1 IDeckLinkVideoInputFrame::GetStreamTime method
Offline

Steffen Pätzold

  • Posts: 21
  • Joined: Mon Mar 30, 2015 10:35 am
  • Location: Leipzig, Germany

Re: Synchronous Record/Playback with Decklink Quad 2 using S

PostThu Oct 12, 2017 5:30 am

The IDeckLinkVideoInputFrame::GetStreamTime only seems to work when the videosignal is constantly present.
I tested what would happen when the video cable is removed and pluged-in again ( a scenario that might happen in production) and the results from IDeckLinkVideoInputFrame::GetStreamTime and IDeckLinkVideoInputFrame::GetHardwareReferenceTimestamp dit not match anymore:

Hardware ; StreamTime
14753338200 ; 868000
14753339197 ; 869000
14753340198 ; 870000
--> Videocable pluged
14753341319 ; 872000 --> Diff: 1121 vs. 2000
14753342323 ; 873000
14753343323 ; 874000

I understand that frames get dropped when the video signal is removed or added, but i expect the values should be in sync again after a few frames.

I just wonder where the Hardware-Timestamp is generated (a clock ticking on the decklink device or a clock on th pc hardware)?
And why is the difference afterwards nearly one frame?

I can reproduce this effect on different computers with different decklinks.
Offline

Cameron Nichols

Blackmagic Design

  • Posts: 442
  • Joined: Mon Sep 04, 2017 4:05 am

Re: Synchronous Record/Playback with Decklink Quad 2 using S

PostThu Oct 19, 2017 6:31 am

Hi Steffen,

I don't see this scenario as unusual. When the video cable is removed, then the stream time uses an unlocked reference clock, whereas the stream time will be (re)locked to the incoming frame time when a video input is detected.

It is possible that due to the change in reference time lock, that time between frames is too short (in your case ~121 hardware cycles) and and hence why GetStreamTime is incremented by 2 frames).

If possible by your application and if you are using a card that supports Input Format Detection[1], my advice is that on IDeckLinkInputCallback::VideoInputFormatChanged[2] callback, call IDeckLinkInput::StartStreams[3] to reset video timing.

Kind Regards
Cameron Nichols

Refs
[1] DeckLink SDK manual - 2.7.17 DeckLink Attribute ID (BMDDeckLinkSupportsInputFormatDetection)
[2] DeckLink SDK manual - 2.5.10 IDeckLinkInputCallback Interface
[3] DeckLink SDK manual - 2.5.4.11 IDeckLinkInput::StartStreams method

Return to Software Developers

Who is online

Users browsing this forum: No registered users and 17 guests