def nearest(ts, img_list):
    """given a timestamp, find the nearest timestamp in img_list"""
    # ts - timestamp
    min_diff = 1000000000000
    min_ts = img_list[0]
    for t in img_list:
        if abs(int(t) - ts) < min_diff:
            min_diff = abs(int(t) - ts)
            min_ts = t
    return min_ts