Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DeckLink] timestamp restart on format change #347

Open
MartinPulec opened this issue Oct 23, 2023 · 2 comments
Open

[DeckLink] timestamp restart on format change #347

MartinPulec opened this issue Oct 23, 2023 · 2 comments
Assignees

Comments

@MartinPulec
Copy link
Collaborator

When format change occurs, timestamps are reset causing libopus warning:

[lavc libopus @ 0x7f29080066c0] Queue input is backward in time

Steps to reproduce:

$ uv -t decklink -s embedded -A Opus -VVV | grep 'Sending PTS\|libopus\|DeckLink'                                                                                                                                               
[1698061079.328] [lavcd aud.] Using audio encoder: libopus
[1698061079.333] [DeckLink capture] Using codec: UYVY
[1698061079.376] [DeckLink capture] Using device UltraStudio 4K
[1698061079.376] [DeckLink capture] bmdDeckLinkConfigCapturePassThroughMode set to: bmdDeckLinkCapturePassthroughModeDisabled
[1698061079.376] [DeckLink capture] bmdDeckLinkConfigVideoInputConnection set to: SDI
[1698061079.376] [DeckLink capture] 625i50 PAL   720 x 576       25 FPS          40000 AVAREGE TIME BETWEEN FRAMES
[1698061079.376] [DeckLink capture] Enable video input: 625i50 PAL
[1698061079.376] [DeckLink] Trying to autodetect format.
[1698061079.377] [DeckLink capture] Audio input set to: embedded
[1698061079.473] [DeckLink capture] Format change detected (display mode, color space - YCbCr422, 10bit).
[1698061079.473] [DeckLink capture] Detected 10-bit signal, use ":codec=UYVY" to enforce 8-bit capture (old behavior).
[1698061079.473] [DeckLink capture] Using codec: v210
[1698061079.473] [DeckLink capture] IDeckLinkDisplayMode::GetName failed: Failed to allocate necessary memory (0x80000002)
[1698061079.473] [DeckLink capture] (NULL!)      1280 x 720      59.9401 FPS     16683 AVAREGE TIME BETWEEN FRAMES
[1698061079.473] [DeckLink capture] Enable video input: (NULL!)
[1698061079.477] [lavc libopus @ 0x7f29080066c0] No bit rate set. Defaulting to 64000 bps.
[1698061079.477] [lavcd aud.] Setting AV frame: 960 samples, format 3, sample rate 48000[1698061079.477] [lavcd aud.] Sending PTS 0
[1698061079.477] [lavcd aud.] Sending PTS 960   
[1698061079.508] [DeckLink capture] Format change detected (field dominance - YCbCr422, 10bit).
[1698061079.530] [lavcd aud.] Sending PTS 0
[1698061079.531] [lavc libopus @ 0x7f29080066c0] Queue input is backward in time
[1698061079.549] [lavcd aud.] Sending PTS 960
[1698061079.566] [lavcd aud.] Sending PTS 1920
[1698061079.582] [lavcd aud.] Sending PTS 2880
[1698061079.597] [lavcd aud.] Sending PTS 3840
[ OK from now ]

When there is format auto-detection, at least on the beginning this occurs once (if using auto-detection). Not sure if this causes some problems now (but possible with DeckLink sync output).

@MartinPulec MartinPulec self-assigned this Oct 23, 2023
MartinPulec added a commit that referenced this issue Oct 23, 2023
affects c1a1f83, 64ecc16

Now audio frames are discarded unless if video signal is not detected,
this doesn't affect situations when just the audio frame is passed.

This refers to GH-347, because it drops the audio frames that are produced
prior signal is detected. Calling IDeckLinkInput::EnableVideoInput restart
timestamps.
@MartinPulec
Copy link
Collaborator Author

This issue shouldn't now occur now (since 5e2815c) when UG starts. It still does when format changes, because DeckLink resets timestaps when IDeckLinkInput::EnableVideoInput() is called (needs to be called with the new format).

Since the timestamp discontinuity doesn't seem to be producing issues (aside the warning), I am considering not solving that. It is perhaps not possible to persuade the BMD API not the reset the timer so it will require to "remember" the offset and adding it to the timestamp from device.

@alatteri
Copy link

alatteri commented Oct 25, 2023

Agreed. Apart from the warning, doesn't seem to actually be creating any negative behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants