Synchronizing StartScheduledPlayback

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

Jason Rhodes

  • Posts: 12
  • Joined: Thu Oct 20, 2016 8:18 pm

Synchronizing StartScheduledPlayback

PostFri Mar 12, 2021 4:07 am

I have a DeckLink Duo 2 card and am trying to synchronize the start (and stop) of playback for all 4 channels for a custom output application.

My app generates frames for each channel asynchronously (via the callback for each completed frame per channel), and I've pre-rolled a few frames for each channel. Then I run a for-loop, calling StartScheduledPlayback(0, ...) for each channel. Naturally, this results in a slight delay for each subsequent channel, as each one starts playback immediately.

According to the SDK, the first parameter to StartScheduledPlayback is "playbackStartTime."

Code: Select all
HRESULT StartScheduledPlayback
  ( BMDTimeValue playbackStartTime,
    BMDTimeScale timeScale,
    double       playbackSpeed );

Unfortunately, there is not a lot of detail given about how to set this parameter.

Can I give it some universal, constant time (slightly in the future) for each channel, so that they all start on the same clock cycle? If so, what is the starting time for "now"?

Do I query the hardware clock, get a value, add a few "timeScale" cycles, then use that value for all channels?

Is this even the right approach for synchronization?
Offline

Cameron Nichols

Blackmagic Design

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

Re: Synchronizing StartScheduledPlayback

PostFri Mar 12, 2021 5:43 am

Hi Jason,

There is built in functionality to synchronise start and stop playback, this feature was added in Desktop Video SDK 11.0. Synchronised Playback is described in high level overview in section 2.4.13.2 and Example SynchonizedPlayback in the SDK package. You need to ensure that a genlock reference input is provided to DeckLink Duo 2.

In brief, the steps to start synchronised playback are:
  1. For each device, set a common ID by writing to bmdDeckLinkConfigPlaybackGroup item IDeckLinkConfiguration::SetInt.
  2. Enable video output on each device by writing to IDeckLinkOutput::EnableVideoOutput, with flag bmdVideoOutputSynchronizeToPlaybackGroup
  3. Wait for reference to be locked by polling status flag bmdDeckLinkStatusReferenceSignalLocked.
  4. Start synchronised playback by calling IDeckLinkOutput::StartScheduledPlayback on any device.
  5. Stop synchronised playback by calling IDeckLinkOutput::StopScheduledPlayback on any device.

Regards
Cameron
Offline

Jason Rhodes

  • Posts: 12
  • Joined: Thu Oct 20, 2016 8:18 pm

Re: Synchronizing StartScheduledPlayback

PostFri Mar 12, 2021 6:02 pm

Thanks, Cameron.

I did forget to mention that the app is currently tied to the 10.7 SDK, but I think we will begin to move towards the 11/12 SDK release for this, as this functionality sounds pretty intuitive and useful.

I'm sure providing support for older SDK version isn't in your best interest, but I am curious if there is any SDK 10 method for even pseudo-synchronization of channel output in the interim. The lack of a "section 2.4.13" in the documentation is probably my answer, however.
Offline

Cameron Nichols

Blackmagic Design

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

Re: Synchronizing StartScheduledPlayback

PostTue Mar 23, 2021 3:02 am

Hi Jason,

Prior to Desktop Video 11.0, there was not a reliable method of synchronizing playback. This is because there is no way to guarantee that multiple calls to IDeckLinkOutput::StartScheduledPlayback will occur in the same frame period.

Regards
Cameron

Return to Software Developers

Who is online

Users browsing this forum: Google [Bot] and 2 guests