问题描述
我正在使用这个项目 https://github.com/apc-llc/moviemaker-cpp 我想知道如何在我的视频上设置固定帧率 现在,当我输入 30FPS 作为 c->framerate 时,结果类似于 33.6 38.1 35.3 我尝试了网上找到的所有内容,但没有机会。
#define FRAMERATE 20
#define FRAME_TIME AVRational{ 1,FRAMERATE }
#define FRAME_RATE AVRational{ FRAMERATE,1 }
...
// Setting up the codec.
AVCodec* codec = avcodec_find_encoder_by_name("libx264"); //libx264 works too!
AVDictionary* opt = NULL;
av_dict_set(&opt,"preset","slow",0);
av_dict_set(&opt,"cfr","30",0);
stream = avformat_new_stream(fc,codec);
c = stream->codec;
c->width = width;
c->height = height;
c->pix_fmt = AV_PIX_FMT_YUV420P;
c->time_base = FRAME_TIME;
c->framerate = FRAME_RATE;
stream->avg_frame_rate = FRAME_RATE;
解决方法
感谢??????????
解决方案是:
您正在寻找的是固定的 gop 和 fps!要实现这一点,只需将流 avg_frame_rate
和 tune
设置为 zerolatency
,仅此而已。
有效!