(not from your code, just found online) Doing this just to get the duration of the video... ```cs pr

(not from your code, just found online) Doing this just to get the duration of the video...
private static TimeSpan? ToTimeInternal(long ts, AVRational time_base, bool is_duration = false)
{
    // sanity check
    if (time_base.den == 0)
    {
        return null;
    }

    if ((!is_duration && ts == ffmpeg.AV_NOPTS_VALUE) || (is_duration && ts == 0))
    {
        return null;
    }

    return new TimeSpan((long)(ts * decimal.Divide(time_base.num, time_base.den) * TimeSpan.TicksPerSecond));
}
Was this page helpful?