FFmepg和VLC冲突问题

使用FFmpeg和VLC的同学要注意了,MobileVLCKit内部重写了一个系统方法clock_gettime,这个方法FFmpeg的av_gettime_relative也用到了。由于VLC的实现问题,这个方法一直返回失败,导致获取的时间有问题。

https://github.com/videolabs/libdsm/blob/master/compat/clock_gettime.c

int clock_gettime(clockid_t clk_id, struct timespec *tp) {
    kern_return_t   ret;
    clock_serv_t    clk;
    clock_id_t clk_serv_id;
    mach_timespec_t tm;

    if (clk_id != CLOCK_REALTIME)
        return -1;

    clk_serv_id = clk_id == CLOCK_REALTIME ? CALENDAR_CLOCK : SYSTEM_CLOCK;
    if (KERN_SUCCESS == (ret = host_get_clock_service(mach_host_self(), clk_serv_id, &clk))) {
        if (KERN_SUCCESS == (ret = clock_get_time(clk, &tm))) {
            tp->tv_sec  = tm.tv_sec;
            tp->tv_nsec = tm.tv_nsec;
        }
    }
    if (KERN_SUCCESS != ret)
        return -1;

    return 0;
}

你可能感兴趣的:(FFmepg和VLC冲突问题)