错误将采样率从AV_SAMPLE_FMT_FLTP转换为AV_SAMPLE_FMT_S16

时间:2013-04-10 05:02:46

标签: macos ffmpeg

将采样率从AV_SAMPLE_FMT_FLTP转换为AV_SAMPLE_FMT_S16并播放openAL,得到以下错误(http://joxi.ru/B_JkUdg5CbDrWhe9oNI

CONV_FUNC (AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16 (lrintf (* (const float *) pi * (1 << 15))))

在文件audioconvert.c中

我的代码

swrContext = swr_alloc();
av_opt_set_int(swrContext, "in_channel_layout",  cc->channel_layout, 0);
av_opt_set_int(swrContext, "out_channel_layout", cc->channel_layout,  0);
av_opt_set_int(swrContext, "in_sample_rate",     cc->sample_rate, 0);
av_opt_set_int(swrContext, "out_sample_rate",    cc->sample_rate, 0);
av_opt_set_sample_fmt(swrContext, "in_sample_fmt",  cc->sample_fmt, 0);
av_opt_set_sample_fmt(swrContext, "out_sample_fmt", AV_SAMPLE_FMT_S16P,  0);
swr_init(swrContext);

uint8_t *output;
int out_samples = (int)av_rescale_rnd(swr_get_delay(swrContext, 44100) + (int64_t)decoded_frame->nb_samples, 44100, 44100, AV_ROUND_UP);
swr_convert(swrContext, &output, out_samples, (const uint8_t **)decoded_frame->extended_data, decoded_frame->nb_samples); //error
alBufferData(BufID,AL_FORMAT_STEREO16,output, decsize,44100);

可能有其他解决方案吗?

可能有其他解决方案吗?我正在进行How to convert sample rate from AV_SAMPLE_FMT_FLTP to AV_SAMPLE_FMT_S16?

1 个答案:

答案 0 :(得分:0)

急于解决问题的输出

uint8_t * output [x];
  • 错误消失