- Posts: 6
- Joined: Thu Jun 18, 2020 7:01 am
- Real Name: Dario Maljur
Hi.
I made a video player using FFMPEG libraries and for each frame I covert it to IDeckLinkMutableVideoFrame that I then output to Ninja2 with DisplayVideoFrameSync. All that is working perfectly.
But I'm having trouble outputting Audio frames.
I get raw audio from FFMPEG AVFrame audio frame which I then send to SDL's audio_callback function. Basically at this point I have a raw uint8_t buffer containing samples.
I then enabled audio output to Ninja with
And from my audio_callback function I send the sample buffer to DeckLink using
This gives me output of slightly higher pitch than it should and I get a lot of noise.
The pitch is probably because the file contains 44Khz audio but the only enumeration for opening audio on DeckLink is 48Khz?
And noise is probably because not all bytes in the buffer are written. I get any number from 2000 to 6000 bytes written.
I tried to make sure that entire buffer is written by using
But this just output loud noise and completely slows my video player.
My question is. Is there a way to change sample rate to other that 48Kkz? If not, how can I output audio of different frequencies to DeckLink and how do I make sure that all the buffer is written?
Thanks,
Dario
I made a video player using FFMPEG libraries and for each frame I covert it to IDeckLinkMutableVideoFrame that I then output to Ninja2 with DisplayVideoFrameSync. All that is working perfectly.
But I'm having trouble outputting Audio frames.
I get raw audio from FFMPEG AVFrame audio frame which I then send to SDL's audio_callback function. Basically at this point I have a raw uint8_t buffer containing samples.
I then enabled audio output to Ninja with
- Code: Select all
EnableAudioOutput(bmdAudioSampleRate48kHz, bmdAudioSampleType16bitInteger,2,bmdAudioOutputStreamContinuous);
And from my audio_callback function I send the sample buffer to DeckLink using
- Code: Select all
WriteAudioSamplesSync(buffer,count,&written);
This gives me output of slightly higher pitch than it should and I get a lot of noise.
The pitch is probably because the file contains 44Khz audio but the only enumeration for opening audio on DeckLink is 48Khz?
And noise is probably because not all bytes in the buffer are written. I get any number from 2000 to 6000 bytes written.
I tried to make sure that entire buffer is written by using
- Code: Select all
while (written < count)
{
unsigned int len = 0;
deckLinkOutput->WriteAudioSamplesSync(&buffer[written],count_left,&len);
written += len;
count_left-=len;
}
But this just output loud noise and completely slows my video player.
My question is. Is there a way to change sample rate to other that 48Kkz? If not, how can I output audio of different frequencies to DeckLink and how do I make sure that all the buffer is written?
Thanks,
Dario