- Posts: 3
- Joined: Mon Nov 17, 2014 12:33 pm
Hi there
I've got some problem during sending audio bytes to Decklink device extreme HD.
The output sound is messy and not clear.
Kindly check the following codes:
Please help me on this issue.
Any help is really appropriated.
I've got some problem during sending audio bytes to Decklink device extreme HD.
The output sound is messy and not clear.
Kindly check the following codes:
- Code: Select all
HRESULT ffmpeg::GetAudioBuffer(_Inout_ uint8_t* pAudioBuffer, _Inout_ int& pAudioBufferSize)
{
HRESULT hr = S_OK;
size_t i = 0;
int gotFrame = 0;
if (av_read_frame(avFormatCtx, avPacket) >= 0)
{
// Is this a packet from the video stream
if (avPacket->stream_index == videoStreamIndex)
{
//Nop...we will use it and unuse openCV
}
else if (avPacket->stream_index == audioStreamIndex)
{
auto ret = avcodec_decode_audio4(audioCodec.pCodecCtx, audioCodec.pFrame, &gotFrame, avPacket);
if (ret < 0)
{
OutputDebugString(L"Error in decoding audio frame");
return hr;
}
if (gotFrame > 0)
{
int outputSamples = swr_convert(
this->audio_convert_ctx,
&pAudioBuffer,
MAX_AUDIO_FRAME_SIZE,
(const uint8_t **) audioCodec.pFrame->data,
audioCodec.pFrame->nb_samples);
pAudioBufferSize = av_samples_get_buffer_size(
NULL,
this->audio_out_channels_layout,
this->out_nb_samples,
this->out_sample_fmt,
1);
}
//free the packet
av_free_packet(avPacket);
}
else
{
//free the packet
av_free_packet(avPacket);
}
}
return hr;
}
- Code: Select all
auto pAudioBuffer = new uint8_t[192000 * 2];
int size = 0;
f.GetAudioBuffer(pAudioBuffer, size);
// Schedule one-frame of audio tone
m_deckLinkOutput->ScheduleAudioSamples(
pAudioBuffer,
size,
0,
bmdAudioSampleRate48kHz,
NULL);
delete [] pAudioBuffer;
if (samplesWritten != size)
{
OutputDebugString(std::to_wstring(samplesWritten).c_str());
OutputDebugString(std::to_wstring(size).c_str());
}
Please help me on this issue.
Any help is really appropriated.