保存avcodec_decode_audio4之后的pcm数据,格式为AV_SAMPLE_FMT_FLTP
FILE *pFile;
FILE *pFile2;
pFile=fopen("d:\\ffplay\\output.pcm", "wb");
pFile2=fopen("d:\\ffplay\\output2.pcm", "wb");
ret = avcodec_decode_audio4(d->avctx, frame, &got_frame, &d->pkt_temp);
if (got_frame) {float* ptr_l = (float*)frame->extended_data[0];
float* ptr_r = (float*)frame->extended_data[1];
for (int i=0; i<frame->nb_samples; i++)
{
fwrite(ptr_l++, sizeof(float), 1, pFile);
fwrite(ptr_r++, sizeof(float), 1, pFile);
fflush(pFile);
}
}
保存swr_convert之后的数据格式为AV_SAMPLE_FMT_S16
len2 = swr_convert(is->swr_ctx, out, out_count, in, af->frame->nb_samples);
if (len2 < 0) {
av_log(NULL, AV_LOG_ERROR, "swr_convert() failed\n");
return -1;
}
fwrite(is->audio_buf1, 1, af->frame->nb_samples*4, pFile2);