ffmpeg设置超时时间

xl_player里的代码,直接复制过来了,不过项目里的超时时间太短了,就给找出来改一下
static int av_format_interrupt_cb(void *data) {
    xl_play_data *pd = data;
    if (pd->timeout_start == 0) {
        pd->timeout_start = xl_clock_get_current_time();//开始时间
        return 0;
    } else {
        uint64_t time_use = xl_clock_get_current_time() - pd->timeout_start;
        if (time_use > 10000000) {//时间,6个0应该是1秒吧,10秒超时
            //超时
            return 1;
        } else {
            return 0;
        }
    }
}
在avformat_alloc_context之后进行设置
pd->format_context = avformat_alloc_context();
pd->format_context->interrupt_callback.callback = av_format_interrupt_cb;
pd->format_context->interrupt_callback.opaque = pd;
xl_clock_get_current_time应该是获取当前时间,单位应该是毫秒
uint64_t xl_clock_get_current_time() {
    struct timeval tv;
    gettimeofday(&tv, NULL);
    return (uint64_t)tv.tv_sec * 1000000 + (uint64_t)tv.tv_usec;
}


 
 

猜你喜欢

转载自blog.csdn.net/u010302327/article/details/79563458