Skip to content

Constant decklink Audio buffer overflow #410

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

Closed
TheSashmo opened this issue Sep 10, 2024 · 20 comments
Closed

Constant decklink Audio buffer overflow #410

TheSashmo opened this issue Sep 10, 2024 · 20 comments

Comments

@TheSashmo
Copy link

TheSashmo commented Sep 10, 2024

I am using these settings for my encoding and decoding, and I am constantly getting decklink audio buffer overflow, I've tried OPUS and and MP3 the result is the same. Any suggestions?

/usr/bin/uv --audio-filter controlport_stats --capture-filter preview:path=/tmp/encode_thumbnail_65.socket:target_size=854x480 -t decklink:connection=sdi:device=0:codec=UYVY -c libavcodec:codec=H.264:encoder=libx264:bitrate=20000000:preset=veryfast:subsampling=420 -s embedded --audio-codec=MP3:sample_rate=48000:bitrate=128k --audio-capture-format channels=16 -f V:rs:: -f A:mult:3 -P 20492 172.18.20.5

/usr/bin/uv --audio-filter controlport_stats -d multiplier decklink:device=0:drift_fix#preview:path=/tmp/decode_thumbnail_65.socket:hq:rate_limit=2:target_size=854x480 -r embedded -P 20492 172.18.20.5

Using latest stable build.

Any suggestions?

@alatteri
Copy link

I think drift_fix is old terminology, and it is now synchronized, also try adding --param use-hw-accel,resampler=soxr to the receiver.

If the encoder or receiver CPU can't keep up, I believe the errors would be similar.

@TheSashmo
Copy link
Author

So replace drift fix with synchronized ?

@TheSashmo
Copy link
Author

But it says its using it by default:

[DeckLink display] Using SoxR resampler by default when DecKlink audio drift fixer is enabled.
[DeckLink display] Using device DeckLink Duo (1)
[DeckLink display] bmdDeckLinkConfigFieldFlickerRemoval set to: false
[DeckLink display] bmdDeckLinkConfigLowLatencyVideoOutput set to: true
[DeckLink display] bmdDeckLinkConfigOutput1080pAsPsF set to: false
[DeckLink display] Using audio output: embedeed

@mikekoetter
Copy link

mikekoetter commented Sep 11, 2024

I might be mistaken, but I don't think synchronized aka sync is a replacement for drift_fix as I don't think it does any resampling. I believe synchronized is a replacement for the deprecated low-latency mode.

Also I believe soxr is already the default resampler now

@alatteri
Copy link

alatteri commented Sep 11, 2024

drift_fix activates a time drift fix for the DeckLink cards with resampler (experimental)

synchronized[=m[,M]] use regular scheduled mode for synchrized output
		(m -  minimum scheduled frames /default 4/, M - max sched
		frames /default 6/), shortcut sync

it was my understanding that synchronized superceded drift_fix

or can they be combined for even more consistency?

@TheSashmo
Copy link
Author

It seems that both options work.

@alatteri
Copy link

one at a time, or combined?

It seems that both options work.

@alatteri
Copy link

alatteri commented Sep 11, 2024

more context here:

#326 (comment)

@TheSashmo
Copy link
Author

TheSashmo commented Sep 11, 2024

Yeah thanks I will look into this, I see that I in fact commented on that thread too complaining about how this would add 100ms of latency, which in the case I am using would be problematic for the setup I am using. Is this option to just keep things in time for audio and video for synchronous playback or can I ignore this option and just yse the audio delay option to be able to keep things sync'd up?

What very very funny is now I don't see the problem anymore. It seems to be gone. The only thing that has changed is a different source was given to me for the encode. Could there be something in the SDI VANC or timecode that is a problem but not being logged as an error in the encoder side, but causes the decoder side to have this problem?

Update: The source now connected a reference signal to their production (not to our encoders) and the issues seems to be gone. Do you think that I should be referencing the cards anyways?

@mikekoetter
Copy link

if you are still getting "buffer overflows" maybe try lowing your mtu.
I've seen a change from -m 1500 to -m 1440 make the difference in more complex networks.

@TheSashmo
Copy link
Author

Well.... that does make sense if the audio and video were interleaved into one packet, but RTP/RTSP normally has audio on one packet and video on another. The audio packets are like 80 and video is 1430, so setting the MTU would only be setting the limit on video packets and not audio.

That being said, I don't have the problem anymore after the client added a sync to their setup. So I am still trying to find out why the problem was happening.

@alatteri
Copy link

maybe @MartinPulec could give us some input on the differences between using :drift_fix and:synchronized with Decklink, and if they are exclusive or there would be benefit in using both at the same time.

@TheSashmo
Copy link
Author

And by the way when I try the synchronized mode, I loose audio on my decoding side.

@MartinPulec
Copy link
Collaborator

I didn't follow the whole discussion (yet?) so I'll just respond specifically to the question:

differences between using :drift_fix and:synchronized with Decklink

  • drift_fix - a resampling buffer is used within DeckLink display module to compensate eventually drifting clocks between the sender and the receiver to mitigate overruns or underruns; no explicit synchronization with the video. But the audio delay is kept more or less consistent so assuming the same holds for video, A/V desync can be compensated with --audio-delay parameter
  • synchronized - at the receiver, timestamped audio and video is re-synchronized (best effort) but not doing any compensation as above. Also audio/video source should be one device (eg. decklink). It may also require some tweaking - there is a arbitrary chosen a (video frame) range in which the "synchronization" is attempted, but it can be adjusted.

Those 2 options are totally incompatible, I believe - the audio resampler in first case drops timestamps - even if it wasn't, the number of samples won't fit the audio time frame*. I don't believe that it can be currently made work together. To use both features, it must have been perhaps done in one component.

* it's hard to explain in few lines - I'd need to go more into details if wanted

@alatteri
Copy link

Thanks for the info @MartinPulec . I've been using :synchronized since it became available, and haven't had complaints from our endpoints. Does seem like a single component that does both drift_fix & syncro would be ideal at some point?

@TheSashmo
Copy link
Author

When I try to use :synchronized I get muted/no audio on the RX side. I am still using drift fix. 1.9.6

@mikekoetter
Copy link

@MartinPulec when using the two sync params, like say sync:10,20. Does that mean that the latency could variably change from 10-20, going up and down in that range throughout the decoding session?

@TheSashmo
Copy link
Author

Bringing this back up to the top to get some help:

Using the following two commands successfully:

/usr/bin/uv --control-port=2209 --audio-filter controlport_stats --capture-filter preview:path=/tmp/encode_thumbnail_209.socket:target_size=854x480 -t decklink:connection=sdi:device=5:codec=UYVY -c libavcodec:codec=H.264:encoder=libx264:bitrate=30000000:preset=superfast:subsampling=420 -s embedded --audio-codec=OPUS:sample_rate=48000:bitrate=128k --audio-capture-format channels=16 -f V:rs:: -f A:mult:3 -P 23374 172.18.20.4

and

/usr/bin/uv --control-port=2209 --audio-filter controlport_stats -d multiplier:decklink:device=7:drift_fix#preview:path=/tmp/decode_thumbnail_209.socket:hq:rate_limit=2:target_size=854x480 -r embedded -P 23374 172.18.20.4

These commands work for me, but what I am seeing that "sometimes" I begin to get random audio buffer overflows on the decoder. This comes and goes over time running the application but I can not seem to find a way why it comes and goes. For the most part this works, but its not flawless. It's all local network testing so highly doubtful its network issues. I've be trying to test the synchronized option, and it seems that this gets rid of my problem, but when I try to put it into my command it doesn't want to work with thumbnails:

/usr/bin/uv --control-port=2209 --audio-filter controlport_stats -d multiplier:decklink:device=7:synchronized#preview:path=/tmp/decode_thumbnail_209.socket:hq:rate_limit=2:target_size=854x480 -r embedded -P 23374 172.18.20.4

and

/usr/bin/uv --control-port=2209 --audio-filter controlport_stats -d multiplier:decklink:device=7:synchronized=4,6#preview:path=/tmp/decode_thumbnail_209.socket:hq:rate_limit=2:target_size=854x480 -r embedded -P 23374 172.18.20.4

Both of these last two command don't output any audio and are throwing tons of overflow errors:
[DeckLink display] Missing frame
[DeckLink display] Dismissed frame, buffered: 6
[DeckLink display] audio buffer overflow!

If I drop the multiplier it's able to work with these commands:

/usr/bin/uv --param window-title=qframe2_ultragird_decode_process_209 --control-port=2209 --audio-filter controlport_stats -d decklink:device=7:synchronized -r embedded -P 23374 172.18.20.4

and

/usr/bin/uv --control-port=2209 --audio-filter controlport_stats -d decklink:device=7:synchronized=4,6 -r embedded -P 23374 172.18.20.4

Is it a multiplier issue or I am missing something to separate the thumbnail generator in the miltiplier? I tried to move the sync command elsewhere into the output device argument but it's same result. If I use drift_fix the command works just fine but has the audio over/under flows on the decoder.

Using 1.9.6 release.

@TheSashmo
Copy link
Author

Just trying to bring this to the top. @MartinPulec any thoughts?

@TheSashmo
Copy link
Author

Closing this and opening a new one for different issue..

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

4 participants