当前位置:  开发笔记 > 编程语言 > 正文

尝试在FFMPEG C项目中使用openH264替代libX264

如何解决《尝试在FFMPEGC项目中使用openH264替代libX264》经验,为你挑选了0个好方法。

我有一个应用程序使用FFMPEG和x264编码器逐帧转码视频.我希望发布这个应用程序,但x264的许可使我转而使用openh264.

我设法顺利编译所有内容(openh264然后FFMPEG与enable-openh264).我现在正在尝试纠正我的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成功编码时的输入相同)

推荐阅读
李桂平2402851397
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有