检查avcodec_find_encoder()here的签名:
AVCodec* avcodec_find_encoder(enum AVCodecID id)
它返回一个AVCodec 结构指针。那么让我们看看AVCodec struct 可以告诉我们here:
const char * name
const char * long_name
// Log or print either of them will show you the encoder name.
printf("%s\n", encoder->name);
printf("%s\n", encoder->long_name);
默认情况下,AV_CODEC_ID_H264 将选择 libx264。
另一种方法是检查ffmpeg源,尝试在libavcodec/目录中搜索编码器ID。通常一个编码器AVCodec struct 会在一个c 源文件的末尾,包括名称、长名称和ID。例如下面的结构在libavcodec/libx264.c:
AVCodec ff_libx264_encoder = {
.name = "libx264",
.long_name = NULL_IF_CONFIG_SMALL("libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_H264,
.priv_data_size = sizeof(X264Context),
.init = X264_init,
.encode2 = X264_frame,
.close = X264_close,
.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,
.priv_class = &x264_class,
.defaults = x264_defaults,
.init_static_data = X264_init_static,
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE |
FF_CODEC_CAP_INIT_CLEANUP,
};
关于其他编解码器,h264_nvenc 和 nvenc_h264 与 NVIDIA GPU 编码器相同;各种硬件支持vaapi和vdpau; h264_cuvid 是 cuda 解码支持,同样由 NVIDIA GPU 提供。如果您需要任何这些编解码器,请通过avcodec_find_encoder_by_name() 获取。