zoukankan      html  css  js  c++  java
  • 解决ffmpeg打开流各种超时问题

    1.设置rtsp超时

    AVDictionary* opts = NULL;

    av_dict_set(&opts, "rtsp_transport", m_bTcp ? "tcp" : "udp", 0); //设置tcp or udp,默认一般优先tcp再尝试udp
    av_dict_set(&opts, "stimeout", "3000000", 0);//设置超时3秒

    int ret = avformat_open_input(&ctx, url, NULL, &opts);

    2.设置udp,http超时

    AVDictionary* opts = NULL;

    av_dict_set(&opts, "timeout", "3000000", 0);//设置超时3秒

    int ret = avformat_open_input(&ctx, url, NULL, &opts);

    3.设置av_read_frame 超时

    auto ctx = avformat_alloc_context();
    ctx->interrupt_callback.callback = CheckInterrupt;//超时回调
    ctx->interrupt_callback.opaque = this;

    //

    m_tStart = time(NULL);

    av_read_frame(ctx, &pkt);

    //超时回调函数

    static int CheckInterrupt(void* ctx)
    {
      auto p = (xxx*)ctx;
      return time(NULL) -  p->m_tStart >= 3 ? 1 : 0;//3秒超时
    }

  • 相关阅读:
    四则运算
    自我介绍
    代练第七天
    代练第六天
    代练第五天
    代练第四天
    补充总结
    对软件工程课程的总结
    作业4:结对编程项目四则运算
    psp记录个人项目花费时间
  • 原文地址:https://www.cnblogs.com/lidabo/p/15684617.html
Copyright © 2011-2022 走看看