我目前正在尝试使用 avi 容器内的一些视频对一些原始音频数据进行编码。
使用的视频编解码器是 mpeg4,我想使用 PCM_16LE 作为音频编解码器,但我面临着一个问题AVCodec->frame_size音频样本的参数。
完成所有正确的分配后,我尝试分配音频帧,对于 AV_CODEC_ID_PCM_S16LE 编解码器,我没有获取样本缓冲区大小所需的编解码器frame_size。因此样本缓冲区大小很大,我根本无法分配这么大的内存量。
有人知道如何绕过这个问题以及如何手动计算frame_size?
frame = av_frame_alloc();
if(!frame)
{
return NULL;
}
//Problem is right here with the frame_size
frame->nb_samples = m_pAudioCodecContext->frame_size;
frame->format = m_pAudioStream->codec->sample_fmt;
frame->channel_layout = m_pAudioStream->codec->channel_layout;
//The codec gives us the frame size, in samples, so we can calculate the size of the samples buffer in bytes
//This returns a huge value due to a null frame_size
m_audioSampleBufferSize = av_samples_get_buffer_size(NULL,
m_pAudioCodecContext->channels,
m_pAudioCodecContext->frame_size,
m_pAudioCodecContext->sample_fmt,
0);
感谢您的帮助,
Robert
正如你所看到的pcm_encode_init函数于pcm.c
All pcm
编码器有frame_size = 0;
. Why?
因为在所有 PCM 格式中“事实上”没有像帧这样的东西,所以本质上不存在压缩PCM
.
所以你应该自己决定要在缓冲区中存储多少样本
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)