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;
        }


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM