1

我正在使用这个项目https://github.com/apc-llc/moviemaker-cpp 我想知道如何在我的视频上设置固定帧率,当我输入 30FPS 作为 c-> 时,它的结果就像 33.6 38.1 35.3帧率我尝试了在网上找到的所有内容,但没有机会。

我尝试了什么:在https://github.com/apc-llc/moviemaker-cpp/blob/319be27849fc3d55a9dc3b0180a5d4ac84e24121/src/writer.cpp#L54

#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;
4

1 回答 1

0

谢谢

解决方案是:

您正在寻找的是固定 gop 和 fps!实现刚刚设置的流avg_frame_ratetuneto zerolatency,仅此而已。

有用!

于 2021-04-21T22:09:01.893 回答