Tag: libx264

如何使用FFmpeg C API对H.264video进行编码,然后使用媒体播放器打开输出?

我正在尝试使用FFMPEG C API对H.264video进行编码。 我已经成功编译并执行了FFMPEG提供的解码/编码示例 。 我面临的问题是.mpg文件(用AV_CODEC_ID_MPEG1VIDEO编码)这个例子创建了作品。 Windows会创建缩略图和所有内容。 另一方面,.h264(用AV_CODEC_ID_H264编码)文件没有。 当我尝试在VLC中播放文件时,播放/暂停按钮只是闪烁,窗口中没有缩略图,没有任何内容。 在编码期间,libx264报告以下内容: [libx264 @ 004b81a0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX [libx264 @ 004b81a0] profile High, level 1.3 [libx264 @ 004b81a0] frame I:3 Avg QP:26.79 size: 2116 [libx264 @ 004b81a0] frame P:12 Avg QP:26.60 size: 789 [libx264 @ 004b81a0] frame B:10 Avg QP:31.39 size: 499 […]

如何用libavcodec / x264编码h.264?

我试图使用libavcodec / libavformat编码video。 音频效果很好,但当我尝试编码video时,我收到以下错误: [libx264 @ 0x10182a000]broken ffmpeg default settings detected [libx264 @ 0x10182a000]use an encoding preset (vpre) 使用命令行ffmpeg很容易修复,但我试图在C中执行此操作。我的选项是 AVStream *pVideoOutStream = av_new_stream(pOutFormatCtx, 0); AVCodecContext *pVideoOutCodecCtx = pVideoOutStream->codec; pVideoOutCodecCtx->codec_id = CODEC_ID_H264; pVideoOutCodecCtx->codec_type = CODEC_TYPE_VIDEO; pVideoOutCodecCtx->bit_rate = pVideoInCodecCtx->bit_rate; pVideoOutCodecCtx->width = pVideoInCodecCtx->width; pVideoOutCodecCtx->height = pVideoInCodecCtx->height; pVideoOutCodecCtx->pix_fmt = pVideoInCodecCtx->pix_fmt; pVideoOutCodecCtx->sample_rate = pVideoInCodecCtx->sample_rate; pVideoOutCodecCtx->gop_size = 30; 但是avcodec_open()失败了。 我需要设置哪些其他值才能使x264满意?