FFmpeg中使用av_seek_frame()回退报错
使用场景:比如正在写入第30秒的视频,使用av_seek_frame跳转到第10秒再进行写入
报错如下:
[rtsp @ 000002532a4e9040] Application provided invalid, non monotonically increasing dts to muxer in stream 1: 14204959 >= 13978655
FFmpeg中使用av_seek_frame()回退报错
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
3条回答 默认 最新
关注 Gpt辅助回答,我来为你把关
// 示例代码 AVFormatContext *formatCtx;
AVStream *videoStream;
AVCodecContext *codecCtx;
AVCodec *codec;
// 初始化FFmpeg av_register_all();
avformat_network_init();
// 打开输入流 avformat_open_input(&
formatCtx, "
input.mp4"
, NULL, NULL);
avformat_find_stream_info(formatCtx, NULL);
// 寻找视频流 videoStream = av_find_best_stream(formatCtx, AVMEDIA_TYPE_VIDEO, -1, -1, &
codec, 0);
// 初始化解码器 codecCtx = avcodec_alloc_context3(codec);
avcodec_parameters_to_context(codecCtx, videoStream->
codecpar);
avcodec_open2(codecCtx, codec, NULL);
// 找到要跳转到的时间 int64_t timestamp = 10 * AV_TIME_BASE;
// 10秒 int streamIndex = videoStream->
index;
// 跳转 av_seek_frame(formatCtx, streamIndex, timestamp, AVSEEK_FLAG_BACKWARD);
// 在这里继续写入视频在使用
av_seek_frame
时,需要确保传入的时间戳是递增的,也就是说要确保跳转到的时间戳比当前时间戳要小。如果时间戳不是递增的,就会出现类似“Application provided invalid, non monotonically increasing dts to muxer”这样的错误。因此在使用av_seek_frame
前,需要先判断要跳转的时间是否合法,确保时间戳是递增的。
有问题你别着急,评论留言都可以,看到马上就回复,尽量及时补充齐解决 无用评论 打赏 举报 编辑记录
悬赏问题
- ¥15 Opencv(C++)异常
- ¥15 VScode上配置C语言环境
- ¥15 汇编语言没有主程序吗?
- ¥15 这个函数为什么会爆内存
- ¥15 无法装系统,grub成了顽固拦路虎
- ¥15 springboot aop 应用启动异常
- ¥15 matlab有关债券凸性久期的代码
- ¥15 lvgl v8.2定时器提前到来
- ¥15 qtcp 发送数据时偶尔会遇到发送数据失败?用的MSVC编译器(标签-qt|关键词-tcp)
- ¥15 cam_lidar_calibration报错