小编kai*_*nfr的帖子

FFmpeg - 从AV_SAMPLE_FMT_FLTP重新采样到AV_SAMPLE_FMT_S16的声音质量非常差(慢,失调,噪音)

我对新ffmpeg的重新取样结果感到困惑.我将AAC音频解码为PCM,ffmpeg将音频信息显示为:

Stream #0:0: Audio: aac, 44100 Hz, stereo, fltp, 122 kb/s
Run Code Online (Sandbox Code Playgroud)

在新的ffmpeg中,输出样本是fltp格式,所以我必须将它从AV_SAMPLE_FMT_FLTP转换为AV_SAMPLE_FMT_S16

PS:在旧的ffmpeg中作为libavcodec 54.12.100,它直接是S16,因此不需要重新采样且没有任何声音质量问题.

然后我尝试了三种方法重新取样,

  1. 使用swr_convert

  2. 使用avresample_convert

  3. 转换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); …
Run Code Online (Sandbox Code Playgroud)

audio ffmpeg aac pcm resampling

7
推荐指数
1
解决办法
1万
查看次数

FFMpeg - 解码视频H264并发出警告:SEI类型被截断; 错误隐瞒; 没有加速的色彩空间转换

调用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.
....
Run Code Online (Sandbox Code Playgroud)

虽然,got_picture仍然返回1,但视频质量不好,经常模糊和闪烁.有什么问题?我该怎么办?谢谢!

ffmpeg h.264

6
推荐指数
1
解决办法
2093
查看次数

标签 统计

ffmpeg ×2

aac ×1

audio ×1

h.264 ×1

pcm ×1

resampling ×1