Reputation: 39
I'm reusing the sample code from the developer 64-bit release of FFmpeg in my application to encode a video:
AVCodec* pCodec_{nullptr};
AVCodecContext* pContext_{nullptr};
avcodec_register_all();
pCodec_ = avcodec_find_encoder(AV_CODEC_ID_MPEG2VIDEO);
if (!pCodec_) {}
pContext_ = avcodec_alloc_context3(pCodec_);
if (!pContext_) {}
pContext_->bit_rate = 400000;
pContext_->width = size.width();
pContext_->height = size.height();
pContext_->time_base.den = 1;
pContext_->time_base.num = fps;
pContext_->gop_size = 10;
pContext_->max_b_frames = 1;
pContext_->pix_fmt = AV_PIX_FMT_BGR0;
if (codec_id == AV_CODEC_ID_H264) {
av_opt_set(pContext_->priv_data, "preset", "slow", 0);
}
int err = avcodec_open2(pContext_, pCodec_, nullptr);
if (err < 0) {}
AVCodec*
and AVCodecContext*
look like they are allocated correctly. avcodec_open2
then returns invalid argument (-22
).
I use: Windows 10 64, VS2013 Compiler, Qt Creator IDE, ffmpeg(2016-05-12) 64bit.
The sample I took the code from is decoding_encoding.c.
Any ideas?
Upvotes: 3
Views: 7543
Reputation: 1823
Just some Ideas:
Upvotes: 1