ffmpeg 动态修改码率
在transcode中加入
/* lvyunxiang add */
static int count = 0;
count++;
if (count == 4000)
{
printf("lvyunxiang test output_streams[0]->enc_ctx->bit_rate=%d\n",output_streams[0]->enc_ctx->bit_rate);
avcodec_close(output_streams[0]->enc_ctx);
output_streams[0]->enc_ctx->bit_rate = 20000000;
int ret = avcodec_open2(output_streams[0]->enc_ctx, output_streams[0]->enc, NULL);
av_log(NULL, AV_LOG_ERROR, "lvyunxiang test*****************ret=%d,output_streams[0]->enc_ctx->bit_rate=%d\n",ret,output_streams[0]->enc_ctx->bit_rate);
int b = ret;
}
https://blog.csdn.net/liuchen1206/article/details/79461434
static int count = 0;
count++;
if (count == 10000)
{
printf("lvyunxiang test output_streams[0]->enc_ctx->bit_rate=%d\n",output_streams[0]->enc_ctx->bit_rate);
int frame_count = output_streams[0]->enc_ctx->frame_number;
avcodec_close(output_streams[0]->enc_ctx);
output_streams[0]->enc_ctx->bit_rate = 10000000;
//output_streams[0]->enc_ctx->time_base.num = 25;
//output_streams[0]->enc_ctx->time_base.den = 1;
int ret = avcodec_open2(output_streams[0]->enc_ctx, output_streams[0]->enc, NULL);
output_streams[0]->enc_ctx->frame_number = frame_count;
av_log(NULL, AV_LOG_ERROR, "lvyunxiang test*****************ret=%d,output_streams[0]->enc_ctx->bit_rate=%d,frame_count=%d\n",ret,output_streams[0]->enc_ctx->bit_rate,output_streams[0]->enc_ctx->frame_number);
int b = ret;
}