我有一个应用程序,它使用ffmpeg和x264编码器逐帧转码视频。我希望发布这个应用程序,但是x264的许可使我转而使用openh264。
我成功地编译了所有东西(openh264然后使用enable-openh264编译ffmpeg)。我现在正试图纠正我的C代码中的编码器设置,因为为libx264工作的代码不再工作了。不幸的是,我发现了非常有限的C/F++示例FFMPEG/OpenH264,我很感激任何链接/提示。
我正在使用以下代码(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成功编码时的输入相同)

最佳答案

警告建议您在设置比特率之前必须设置一个framedrop模式,因为它正在将比特率设置为0。

关于c - 尝试在FFMPEG C项目中使用openH264替代libX264,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34104764/

10-09 21:52