I'm using ffmpeg (version 5.1.2) to clip a mp4 video per frame so I need to decode and encode it. However, when I'm creating the encoder for its video stream, the program always crashes at the call to avio_open2()
, after H264 gives this error message:
[h264_mf @ 0000025C1EBC1900] could not set output type (80004005)
The configuration (time_base, pix_fmt, width, height) of the codec context of the encoder is copied from the decoder, and I checked if the pixel format is supported by finding if it's in codec->pix_fmts
.
I find that the problem does not involve all my other pieces of code, because this minimal program can duplicate the same problem:
extern "C"
{
#include <libavcodec/avcodec.h>
}
int main()
{
auto codec = avcodec_find_encoder(AV_CODEC_ID_H264);
auto codec_ctx = avcodec_alloc_context3(codec);
codec_ctx->pix_fmt = AV_PIX_FMT_YUV420P;
codec_ctx->width = 2560;
codec_ctx->height = 1440;
codec_ctx->time_base.num = 1; codec_ctx->time_base.den = 180000;
avcodec_open2(codec_ctx, codec, NULL);
return 0;
}
Then I suspect if it's a bug of ffmpeg. My environment is Windows 11 64-bit, Visual Studio 2022. The ffmpeg library is obtained from vcpkg, as shown in the following image: