不推荐使用 AVStream.codec.time_base 作为复用器的时基提示.改为设置AVStream.time_

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

本文关键字:time AVStream 复用器 设置 提示 base codec      更新时间:2023-10-16

我正在使用MMPEGC API并收到此消息。所以我在我的直播中添加了time_base

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

并在上下文中摆脱了它

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)立即中断

为什么?我是否需要将值应用于它们?我已经将值复制到了两者,并且消息消失了。但这不是错了吗

设置codecContext->time_base值是必需的,不应跳过。取消注释,您应该没事。另请参阅 ffmpeg 提供的代码示例。

至于为什么需要这两个值:AVStreamAVCodecContext是两种不同的结构,可能会也可能不会一起使用,具体取决于您的代码需要做什么。他们都需要一个time_base所以他们都有。您可以称其为 ffmpeg 代码库中的众多特性之一。