本文共 1172 字,大约阅读时间需要 3 分钟。
#include#include int main(){ // init cv::VideoWriter outputVideo; cv::Size S = cv::Size(width_output, height_output); int fourcc = cv::VideoWriter::fourcc('H','2','6','4'); int fps = 25; outputVideo.open(output_file, fourcc, fps, S); // write frame outputVideo.write(frame); // deinit outputVideo.release(); return 0; }
#if LIBAVUTIL_BUILD > CALC_FFMPEG_VERSION(51,11,0) /* Some settings for libx264 encoding, restore dummy values for gop_size and qmin since they will be set to reasonable defaults by the libx264 preset system. Also, use a crf encode with the default quality rating, this seems easier than finding an appropriate default bitrate. */ if (c->codec_id == AV_CODEC_ID_H264) { c->gop_size = -1; c->qmin = -1; c->bit_rate = 0; if (c->priv_data) av_opt_set(c->priv_data,"crf","21", 0); av_opt_set(c->priv_data,"preset","faster", 0); }#endif
上面的代码,修改了crf参数,23修改为21
添加了preset参数的设置; 大家可以参考一下转载地址:http://bmfli.baihongyu.com/