gpt4 book ai didi

c - 尝试在 FFMPEG C 项目中使用 openH264 作为 libX264 的替代品

转载 作者:太空狗 更新时间:2023-10-29 17:04:19 59 4
gpt4 key购买 nike

我有一个使用 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 成功编码时的输入相同)

最佳答案

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

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

59 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com