user1496491
user1496491

Reputation: 583

Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead

I'm using C API of MMPEG and getting this message. So I added time_base to my stream

videoStream = avformat_new_stream(formatContext, codec);
videoStream->time_base = AVRational{1, fps};

and got rid of it in context

codecContext->bit_rate = 400000;
codecContext->width = width;
codecContext->height = height;
codecContext->gop_size = 10;
codecContext->max_b_frames = 1;
//codecContext->time_base = AVRational{1, fps};
codecContext->pix_fmt = AV_PIX_FMT_YUV420P;

avcodec_open2(codecContext, codec, NULL) immediately breaks

WHY? Do I need to apply the value to both of them? I've duplicated values to both, and the message gone. But isn't it just wrong?

Upvotes: 1

Views: 3151

Answers (1)

MadMarky
MadMarky

Reputation: 263

Setting the codecContext->time_base value is mandatory and should not be skipped. Uncomment it and you should be fine. Also see the code example that ffmpeg provided.

As to why both values are needed: AVStream and AVCodecContext are two different structures that may or may not be used together, depending on what your code needs to do. They both need a time_base so they both have them. You may call it one of the many peculiarities in the ffmpeg codebase.

Upvotes: 1

Related Questions