Skip to content

Decklink: Convert to frame scheduling and use preroll [DRAFT]#4565

Closed
tt2468 wants to merge 1 commit intoobsproject:masterfrom
tt2468:decklink-desync
Closed

Decklink: Convert to frame scheduling and use preroll [DRAFT]#4565
tt2468 wants to merge 1 commit intoobsproject:masterfrom
tt2468:decklink-desync

Conversation

@tt2468
Copy link
Member

@tt2468 tt2468 commented Apr 21, 2021

Description

This PR is a draft. I am using it to produce test builds for windows.

Changes:

  • Switches decklink output to the Decklink SDK's frame scheduling system instead of synchronous frame writing
  • Audio packets are now written to the buffer synchronously, to avoid samples being dropped.
  • Implemented av preroll to fill the buffer before starting playout.
  • Compared to Decklink: Use frame scheduling API to fix output audio drift #1865, this fills the video frame buffer according to an explicit number of frames instead of time.

Current Issues:

  • After a few minutes, decklink starts reporting frames as bmdOutputFrameDisplayedLate, however frames are never actually dropped by decklink.
  • After a few hours, OBS appears to start dropping frames. I have not figured out why, but decklink does not report any dropped frames still.

Fixed Issues:

  • Audio and video now stay perfectly synced with each other. Tested for almost 6 hours yesterday. Neither of the above issues affect synchronization.

Motivation and Context

The current decklink output implementation synchronously writes data to decklink. The correct method is to schedule frames with timestamps, and let decklink handle writing the scheduled frames. This PR uses reference from #1865, with additional fixes and changes that I've made during my own testing process.

How Has This Been Tested?

I run an AV sync test on loop on a media source, outputting via a Decklink Duo 2 to a display. Measuring sync with my phone's slow motion recording.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Performance enhancement (non-breaking change which improves efficiency)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@VodBox VodBox added the Seeking Testers Build artifacts on CI label Apr 21, 2021
@WizardCM WizardCM added the Bug Fix Non-breaking change which fixes an issue label Apr 21, 2021
@WizardCM WizardCM requested a review from DDRBoxman August 22, 2021 09:53
@ogmkp
Copy link

ogmkp commented Jan 7, 2022

Tested on OBS 27.2.0-beta2 Debian 11.
I can't enable decklink output on the first BNC connector but 3 others works.
Is there a way to reduce CPU consumption for decklink output ?

@tt2468
Copy link
Member Author

tt2468 commented Apr 30, 2022

Is there a way to reduce CPU consumption for decklink output ?

Decklink output currently enables the frame scaler 24/7, regardless of whether it is required. I'll be working on a change to only enable it when necessary soon.

@tt2468 tt2468 closed this May 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Fix Non-breaking change which fixes an issue Seeking Testers Build artifacts on CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants