尝试在FFMPEG C项目中使用openH264作为libX264的替代方案

17
我有一个应用程序,使用FFMPEG和x264编码器逐帧转码视频。我想发布这个应用程序,但是x264的许可证使我改用openh264。
我成功地编译了所有东西(先是openh264,然后是启用openh264的FFMPEG)。现在我正在尝试在我的C代码中纠正编码器设置,因为对libx264有效的设置不再起作用了。不幸的是,我发现FFMPEG/openh264的C/C++示例非常有限,如果您有任何链接/提示,我将不胜感激。
我正在使用以下代码(dec_ctx是我解码的视频的AVCodecContext)。
            enc_ctx->height = dec_ctx->height;
            enc_ctx->width = dec_ctx->width;
            enc_ctx->sample_aspect_ratio = dec_ctx->sample_aspect_ratio;
            /* take first format from list of supported formats */
            enc_ctx->pix_fmt = encoder->pix_fmts[0];
            /* video time_base can be set to whatever is handy and supported by encoder */
            enc_ctx->time_base = dec_ctx->time_base;

            enc_ctx->gop_size      = 120; /* emit one intra frame every twelve frames at most */
            enc_ctx->max_b_frames = 16;
            enc_ctx->scenechange_threshold = 0;
            enc_ctx->rc_buffer_size = 0;
            enc_ctx->me_method = ME_ZERO;

            enc_ctx->ticks_per_frame = dec_ctx->ticks_per_frame * ifmt_ctx->streams[i]->time_base.den * ifmt_ctx->streams[i]->r_frame_rate.num/ifmt_ctx->streams[i]->r_frame_rate.den;
            // Set Ultrafast profile. internal name for this preset is baseline
            av_opt_set(enc_ctx->priv_data, "preset", "placebo", AV_OPT_SEARCH_CHILDREN);

我在输出中遇到了以下带有[OpenH264]标签的错误信息:
[OpenH264] this = 0x0000000019C126C0, Warning:bEnableFrameSkip = 0,bitrate can't be controlled for RC_QUALITY_MODE,RC_BITRATE_MODE and RC_TIMESTAMP_MODE without enabling skip frame.
Output #0, mp4, to 'C:\Dev\temp\geoVid.mp4':
Stream #0:0: Video: h264 (libopenh264), yuv420p, 720x480, q=2-31, 200 kb/s, 90k tbn, 180k tbc
Stream #0:1: Audio: aac, 48000 Hz, stereo, fltp, 96 kb/s
[OpenH264] this = 0x0000000019C126C0, Warning:Actual input framerate fAverageFrameRate = 0.000000 is quite different from framerate in setting 60.000000, please check setting or timestamp unit (ms), start_Ts = 0
[OpenH264] this = 0x0000000019C126C0, Warning:Actual input framerate fAverageFrameRate = 0.000000 is quite different from framerate in setting 60.000000, please check setting or timestamp unit (ms), start_Ts = 0

输出视频文件只播放黑帧。如果有任何提示或文档链接将不胜感激。我一直在尝试理解这些错误,但不太确定如何启用“跳过帧”或者为什么它在抱怨我的输入帧速率(这是当我使用libx264进行编码时的相同输入)。
1个回答

1
警告提示您在设置比特率之前必须设置帧丢失模式,因此它将比特率设置为0。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接