1、编码流程与视频相同
2、编码函数avcodec_encodec_audio2
codec = avcodec_find_encoder_by_name("libfdk_aac")
c = avcodec_alloc_context3(codec) // 创建上下文
c->bit_rate = 64000; // 设置码率
c->sample_fmt = AV_SAMPLE_FMT_S16
// select other audio parameters supported by the encoder
c->sample_rate = select_sample_rate(codec); //也可以自己设置48k,24k,16k,8k
c->channel_layout = select_channel_layout(codec); //立体声还是单声道,可以自己设置
c->channels = av_get_channel_layout_nb_channels(c->channel_layout);
frame = av_frame_alloc();
frame->nb_samples = c->frame_size;
frame->format = c->sample_fmt;
frame->channel_layout = c->channel_layou;










网友评论