修改视频分辨率
-vsync 1 -re -i /data/yipu.ts -async 1 -y -filter_complex split=outputs=1:[proxy0],[proxy0]scale=1920:1080 -rtpflags +latm -8x8dct 1 -profile:v high10 -level 40 -bufsize 6000000 -minrate 8000000 -maxrate 8000000 -muxrate 1 -rc_init_occupancy 7200000 -bt 800000 -aud 1 -mbtree 0 -mixed-refs 0 -fast-pskip 1 -vflags +cgop -b_strategy 1 -b-bias 12 -trellis 0 -bidir_refine 0 -vflags +loop -deblock -2:-2 -cmp chroma -psy 0 -weightb 0 -weightp 1 -b-pyramid 0 -subq 4 -coder 1 -qcomp 0.01 -direct-pred auto -aq-strength 0.8 -i_qfactor 0.7 -b_qfactor 1.2 -nr 0 -x264opts chroma_qp_offset=12:ipratio=1.40:pbratio=1.20:force_cfr -pix_fmt yuv420p -r 25 -b:v 8000000 -rc-lookahead 4 -g 50 -keyint_min 5 -bf 3 -refs 2 -mbd 0 -me_method dia -me_range 12 -sc_threshold 40 -qmax 50 -qmin 13 -qdiff 4 -vcodec libx264 -max_muxing_queue_size 1024 -b:a 96k -ar:a 44100 -ac:a 2 -codec:a aac -f mpegts output.ts -loglevel verbose -stats
static int change_resolution()
{
printf("lvyunxiang test %%%%%%%%%%% output_streams[0]->enc_ctx->width=%d output_streams[0]->enc_ctx->height=%d\n",output_streams[0]->enc_ctx->width,output_streams[0]->enc_ctx->height);
avcodec_close(output_streams[0]->enc_ctx);
output_streams[0]->enc_ctx->width = 1280;
output_streams[0]->enc_ctx->height = 720;
int ret = avcodec_open2(output_streams[0]->enc_ctx, output_streams[0]->enc, NULL);
printf("lvyunxiang &&&&&&&&&&& =%d %d %d \n",ret,output_streams[0]->enc_ctx->width,output_streams[0]->enc_ctx->height);
//这里不能少
avcodec_copy_context(output_streams[0]->st->codec, output_streams[0]->enc_ctx);
avcodec_parameters_from_context(output_streams[0]->st->codecpar, output_streams[0]->enc_ctx);
//获取过滤器参数
char filter_cmd[1024]={0};
memset(filter_cmd,0,1024);
FilterGraph* video_fg = NULL;
for(int i=0;i< nb_filtergraphs;i++) //遍历所有FilterGraph
{
FilterGraph *fg = filtergraphs[i];
if(fg->nb_inputs > 0) //FilterGraph 输入个数> 0
{
if(fg->inputs[0]->type == AVMEDIA_TYPE_VIDEO)
{
strcpy(filter_cmd,fg->graph_desc);
printf("lvyunxiang$$$$$$$$$$$$$$$$$$$$$$$$$$$ filter_cmd=%s\n",filter_cmd);
video_fg = fg;
avfilter_graph_free(&fg->graph); //释放视频相关的FilterGraph
break;
}
}
}
char* filter_cmd2= malloc(1024);
memset(filter_cmd2, 0, 1024);
snprintf(filter_cmd2,1024,"%s","[0:v]split=outputs=1:[proxy0],[proxy0]scale=1280:720[out0]");
if(video_fg != NULL)
{
video_fg->graph_desc = filter_cmd2;
}
return 0;
}
上面的可以用