CESNET / UltraGrid

UltraGrid low-latency audio and video network transmission system
http://www.ultragrid.cz
Other
492 stars 53 forks source link

--audio-filter delay in frames #220

Closed alatteri closed 2 years ago

alatteri commented 2 years ago

Hi UG Team,

Thanks for adding this on the encoder side. I'm wondering if it would be possible to add an option to delay by # of frames instead of just ms. For instance, in the compression settings, adding frame-threads=5 would make the video 5 frames behind the audio. While I can calculate the ms delay based off an assumed or static FPS "(1000ms/fps)*("frame-threads"-1)" , if the input sources changed FPS, then that calculation is no longer valid. Since BMD auto-detects source signal, hopefully this is possible.

Thanks.

mpiatka commented 2 years ago

Hi,

the audio and video parts of UG are pretty separate, so setting delay to video frames would be a bit problematic. However, I implemented a special mode, that let's you set the delay to "audio frames" instead.

Audio frames are basically chunks of audio data that are read from the capture device and processed together at once. In the case of Decklink embedded audio, the frame time for video and audio frames is the same, so this should probably work fine for you. However, if you use a separate sound card it will not correspond to the video fps at all.

To use this you can add the :frames option. For example to delay by 1s on 24fps video:

uv -t decklink --audio-filter delay:24:frames -s embedded
alatteri commented 2 years ago

This works great!!!! THANK YOU!!!!!!