gpt4 book ai didi

macos - 将采样率从 AV_SAMPLE_FMT_FLTP 转换为 AV_SAMPLE_FMT_S16 时出错

转载 作者:行者123 更新时间:2023-12-04 23:30:32 26 4
gpt4 key购买 nike

将采样率从 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?

最佳答案

赶到问题出问题了

uint8_t * output [x];
  • 错误消失
  • 关于macos - 将采样率从 AV_SAMPLE_FMT_FLTP 转换为 AV_SAMPLE_FMT_S16 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15917323/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com