# Routing Bink Video audio through FMod

**URL:** <https://qa.fmod.com/t/routing-bink-video-audio-through-fmod/21240>\
**Category:** Unreal Engine\
**Tags:** ue5\
**Created:** [February 14, 2024, 8:47am UTC](https://qa.fmod.com/t/routing-bink-video-audio-through-fmod/21240 "2024-02-14T08:47:48Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![alberto.barbati](https://avatars.discourse-cdn.com/v4/letter/a/df788c/32.png) [@alberto.barbati](https://qa.fmod.com/u/alberto.barbati)\
**Post date:** [February 14, 2024, 8:47am UTC](https://qa.fmod.com/t/routing-bink-video-audio-through-fmod/21240/1 "2024-02-14T08:47:48Z")

</div>

Hi,  
our game uses Fmod for all game audio and we are planning to use Bink to play video clips. In order to avoid relying upon the Unreal audio engine, we would like to route the video clips audio to FMod. I believe it should be possible to have Bink stream audio data into a buffer and then use System::createStream, but I am seeking help to address the details.  
TIA,

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [February 15, 2024, 12:41am UTC](https://qa.fmod.com/t/routing-bink-video-audio-through-fmod/21240/2 "2024-02-15T00:41:30Z")

</div>

Hi,

It is recommended to use Bink to play its audio alongside FMOD, is there a specific reason that you want to route the audio through FMOD?

---

<div class="post-metadata">

**Author:** ![alberto.barbati](https://avatars.discourse-cdn.com/v4/letter/a/df788c/32.png) [@alberto.barbati](https://qa.fmod.com/u/alberto.barbati)\
**Post date:** [February 15, 2024, 8:18am UTC](https://qa.fmod.com/t/routing-bink-video-audio-through-fmod/21240/3 "2024-02-15T08:18:51Z")

</div>

Doing so we would need to leave the Unreal audio engine enabled in addition to Fmod and we would like to have only one engine. Consider that our project targets both PC and game consoles.

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [February 16, 2024, 5:30am UTC](https://qa.fmod.com/t/routing-bink-video-audio-through-fmod/21240/4 "2024-02-16T05:30:09Z")

</div>

Hi,

That is understandable, it is possible to have UE audio and FMOD running side by side on console as well if that is a viable option? If not I can look into routing the Bink audio through FMOD.

Could I grab some info?  
What version of FMOD and Unreal Engine are you using? Which consoles are you looking at packaging to?

---

<div class="post-metadata">

**Author:** ![alberto.barbati](https://avatars.discourse-cdn.com/v4/letter/a/df788c/32.png) [@alberto.barbati](https://qa.fmod.com/u/alberto.barbati)\
**Post date:** [February 19, 2024, 7:35am UTC](https://qa.fmod.com/t/routing-bink-video-audio-through-fmod/21240/5 "2024-02-19T07:35:57Z")

</div>

We are using Unreal 5.3 (possibly upgrading to 5.4 during the development of the project) and FModStudio 2.02.18 (updgrade is also possible at this stage).

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [February 19, 2024, 8:42pm UTC](https://qa.fmod.com/t/routing-bink-video-audio-through-fmod/21240/6 "2024-02-19T20:42:20Z")

</div>

Hi,

Thank you for the information. I got Bink and FMOD working together without any changes or issues on PS5. Were you looking at just targeting Sony or any other console?

---

<div class="post-metadata">

**Author:** ![alberto.barbati](https://avatars.discourse-cdn.com/v4/letter/a/df788c/32.png) [@alberto.barbati](https://qa.fmod.com/u/alberto.barbati)\
**Post date:** [February 20, 2024, 8:36am UTC](https://qa.fmod.com/t/routing-bink-video-audio-through-fmod/21240/7 "2024-02-20T08:36:31Z")

</div>

I was told Bink would route the audio on Unreal Audio, and thus would require the Unreal Audio engine to be enabled, but indeed you’re right and Bink does not do that. We can in fact run Bink to play fullscreen video alongside Fmod even on consoles, without modifications and without enabling the Unreal Audio engine. However, I am still wondering if it’s possible to route Bink audio into an FMod event or bus. This could be used, for example, to play a video inside a game element such as a TV screen placed in the 3d scene and have FMod properly spatialize the audio track. We tried playing the audio track separately as a “regular” Fmod event, but audio and video cab easily get de-synced.

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [February 21, 2024, 5:47am UTC](https://qa.fmod.com/t/routing-bink-video-audio-through-fmod/21240/8 "2024-02-21T05:47:09Z")

</div>

Hi,

Unfortunately, I cannot see a way to pass Bink audio to FMOD without significant code changes to both Bink and UE. I looked into implementing drift compensation on the side of Bink, but the API is limited and does not support changing the playback rate of the video.

An option may be using `GetTime` on the Bink media player and `GetTimelinePosition` on an FMOD Audio component and changing the event’s pitch to compensate for drift.

We have recently supported [AudioLink](https://docs.unrealengine.com/5.3/en-US/audiolink/) which allows for UE sounds to be passed to the FMOD system: [Unreal Integration: AudioLink](https://fmod.com/docs/2.02/unreal/audiolink.html). Let me know if this may be a viable option.

---

<div class="post-metadata">

**Author:** ![apfelbaum](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/apfelbaum/32/4843_2.png) [@apfelbaum](https://qa.fmod.com/u/apfelbaum)\
**Post date:** [February 26, 2024, 8:29pm UTC](https://qa.fmod.com/t/routing-bink-video-audio-through-fmod/21240/9 "2024-02-26T20:29:08Z")

</div>

ouh, I also had an idea in this direction. Because I currently have 8 languages in which i have the audio for the same videos so my idea was to play the audio in fmod along with the video in unreal engine but i dont know wether this can be even in sync, ever. or is there a way? all languages audio will be deployed with the game so there will be no different versions of the game. But it doesn’t have to be bink in particular, just any video format that unreal supports, best out of the box.

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [March 5, 2024, 3:22am UTC](https://qa.fmod.com/t/routing-bink-video-audio-through-fmod/21240/10 "2024-03-05T03:22:37Z")

</div>

Hi,

> [@apfelbaum](#):
>
> is there a way?

Yes, unfortunately, it’s more involved than I first thought. It requires accessing the FMOD Core API and influencing the [FMOD::Chanel](https://fmod.com/docs/2.02/api/core-api-channel.html)’s frequency rather than the event’s pitch.

let me know if this is still an option you would like to consider.

---

<div class="post-metadata">

**Author:** ![apfelbaum](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/apfelbaum/32/4843_2.png) [@apfelbaum](https://qa.fmod.com/u/apfelbaum)\
**Post date:** [March 6, 2024, 4:22pm UTC](https://qa.fmod.com/t/routing-bink-video-audio-through-fmod/21240/11 "2024-03-06T16:22:10Z")

</div>

Uh, I know how to change the channel frequency, I do this already for my granular synth plugin. But what would be the logic to sync AV?

Best regards

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [March 13, 2024, 11:10pm UTC](https://qa.fmod.com/t/routing-bink-video-audio-through-fmod/21240/12 "2024-03-13T23:10:36Z")

</div>

Hi,

1. Since we cannot get the samples directly from the Bink Media player we will need to infer how many/how far into the video we are. I found I was able to retrieve `Total milliseconds passed`:  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/3/34c34a6b3a30a9cf95c1490a74ac8b2fc33c8c99.png)  
from Bink. We can use this with [Channel::getPosition](https://fmod.com/docs/2.02/api/core-api-channel.html#channel_getposition) to sync the event and video.
2. Next from the event we will need to find the [channel group](https://fmod.com/docs/2.02/api/studio-api-eventinstance.html#studio_eventinstance_getchannelgroup) with our [channel](https://fmod.com/docs/2.02/api/core-api-channelgroup.html#channelgroup_getchannel)
3. Using the [Video Playback](https://fmod.com/docs/2.02/unity/examples-video-playback.html) example, we will set up the variables for both Bink and FMOD

```auto
UPROPERTY(BlueprintReadWrite)
float binkCurrentMiliseconds = 0;
float binkLastMiliseconds = 0;

unsigned int binkTotalSamplesWritten = 0;
unsigned int binkTotalSamplesRead = 0;
unsigned int binkMinimumSamplesWritten = 0xffffffff;
UPROPERTY(BlueprintReadWrite)
float playbackRate = 1.0;

unsigned int fmodTotalSamplesWritten = 0;
unsigned int fmodTotalSamplesRead = 0;
unsigned int fmodMinimumSamplesWritten = 0xffffffff;

unsigned int binkDriftThreshold = 0;
unsigned int binkTargetLatency = 0;
unsigned int binkAdjustedLatency = 0;
int binkActualLatency = 0;

unsigned int fmodDriftThreshold = 0;
unsigned int fmodTargetLatency = 0;
unsigned int fmodAdjustedLatency = 0;
int fmodActualLatency = 0;

```

1. We will need to convert milliseconds to samples

```auto
unsigned int fmodMiliseconds = 0;
result = channel->getPosition(&fmodMiliseconds, FMOD_TIMEUNIT_MS);

binkLastMiliseconds = binkCurrentMiliseconds;

float binkSeconds = binkLastMiliseconds / 1000.0f;
float fmodSeconds = fmodMiliseconds / 1000.0f;

unsigned int binkSamplesWritten = binkSeconds * sampleRate;
binkTotalSamplesWritten += binkSamplesWritten;

unsigned int fmodSamplesWritten = fmodSeconds * sampleRate;
fmodTotalSamplesWritten += fmodSamplesWritten;

```

1. We will then slightly change the `Drift Compensation` from the video playback for our situation.

```auto
if (binkSamplesWritten != 0 && (binkSamplesWritten < binkMinimumSamplesWritten))
{
    binkMinimumSamplesWritten = binkSamplesWritten;
    binkAdjustedLatency = fmax(binkSamplesWritten, binkTargetLatency);
}

if (fmodSamplesWritten != 0 && (binkSamplesWritten < fmodMinimumSamplesWritten))
{
    fmodMinimumSamplesWritten = binkSamplesWritten;
    fmodAdjustedLatency = fmax(fmodSamplesWritten, fmodTargetLatency);
}

int binkLatency = (int)binkTotalSamplesWritten - (int)binkTotalSamplesRead;
binkActualLatency = (int)((0.93f * binkActualLatency) + (0.03f * binkLatency));

int fmodLatency = (int)fmodTotalSamplesWritten - (int)fmodTotalSamplesRead;
fmodActualLatency = (int)((0.93f * fmodActualLatency) + (0.03f * fmodLatency));

int actualLatencyDifference = fmodActualLatency - binkActualLatency;
int frequency = sampleRate;
if (actualLatencyDifference < -50)
{
    frequency = sampleRate + (int)(sampleRate * (DRIFT_CORRECTION_PERCENTAGE / 100.0f));
    UE_LOG(LogTemp, Warning, TEXT("Slow down"));
}
else if (binkActualLatency > 50)
{
    frequency = sampleRate - (int)(sampleRate * (DRIFT_CORRECTION_PERCENTAGE / 100.0f));
    UE_LOG(LogTemp, Warning, TEXT("Speed Up"));
}
binkTotalSamplesRead += binkSamplesWritten;
fmodTotalSamplesRead += fmodSamplesWritten;
chan->setFrequency(frequency);

```

Hopefully, this will keep the Bink player and Event in sync.
