我对新ffmpeg的重新取样结果感到困惑.我将AAC音频解码为PCM,ffmpeg将音频信息显示为:
Stream #0:0: Audio: aac, 44100 Hz, stereo, fltp, 122 kb/s
在新的ffmpeg中,输出样本是fltp格式,所以我必须将它从AV_SAMPLE_FMT_FLTP转换为AV_SAMPLE_FMT_S16
PS:在旧的ffmpeg中作为libavcodec 54.12.100,它直接是S16,因此不需要重新采样且没有任何声音质量问题.
然后我尝试了三种方法重新取样,
使用swr_convert
使用avresample_convert
转换manualy
但是它们都会产生相同的结果,声音质量非常糟糕,非常缓慢和失调,还有一些噪音.
我的重采样代码如下:
void resampling(AVFrame* frame_, AVCodecContext* pCodecCtx, int64_t want_sample_rate, uint8_t* outbuf){
    SwrContext      *swrCtx_ = 0;
    AVAudioResampleContext *avr = 0;
    // Initializing the sample rate convert. We only really use it to convert float output into int.
    int64_t wanted_channel_layout = AV_CH_LAYOUT_STEREO;
#ifdef AV_SAMPLEING
    avr = avresample_alloc_context();
    av_opt_set_int(avr, "in_channel_layout", frame_->channel_layout, 0);
    av_opt_set_int(avr, "out_channel_layout", wanted_channel_layout, 0);
    av_opt_set_int(avr, "in_sample_rate", frame_->sample_rate, 0);
    av_opt_set_int(avr, "out_sample_rate", 44100, 0); …调用avcodec_decode_video2时(pCodecCtx,pFrame,&got_picture,&packet); 从PMP文件解码H264视频.
我经常收到以下警告:
FF: SEI type 1 size 40 truncated at 36
FF: error while decoding MB 23 15, bytestream (td)
FF: Cannot use next picture in error concealment
...
FF: No accelerated colorspace conversion found from yuv420p to rgb24.
....
虽然,got_picture仍然返回1,但视频质量不好,经常模糊和闪烁.有什么问题?我该怎么办?谢谢!