0
我試圖轉換AAC音頻流進行播放。我發現我需要從AV_SAMPLE_FMT_FLTP轉換爲AV_SAMPLE_FMT_S16,但是當我這樣做時,音頻以大約一半的速度播放。FFmpeg從AAC轉換後緩慢播放音頻
swr = swr_alloc();
assert(av_opt_set_int(swr, "in_channel_layout", audioContext->channel_layout, 0) == 0);
assert(av_opt_set_int(swr, "out_channel_layout", audioContext->channel_layout, 0) == 0);
assert(av_opt_set_int(swr, "in_sample_rate", audioContext->sample_rate, 0) == 0);
assert(av_opt_set_int(swr, "out_sample_rate", 44100, 0) == 0);
assert(av_opt_set_int(swr, "in_sample_fmt", audioContext->sample_fmt, 0) == 0);
assert(av_opt_set_int(swr, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0) == 0);
swr_init(swr);
有我的代碼進行轉換。輸入採樣率是44100,音頻是立體聲。
我調用代碼
swr_convert(swr, &output, aDecodedFrame->nb_samples, (const uint8_t**)aDecodedFrame->extended_data, aDecodedFrame->nb_samples) >= 0)