<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def convert_sample_to_video_time(sample, orig_s_freq, sampleStamp, sampleTime):
 """Convert sample number to video time, using snc information. Parameters sample : int sample that you want to convert in time orig_s_freq : int sampling frequency (used as backup) sampleStamp : list of int Sample number from start of study sampleTime : list of datetime.datetime File time representation of sampleStamp Returns ------- instance of datetime absolute time of the sample. Notes ----- Note that there is a discrepancy of 4 or 5 hours between the time in snc and the time in the header. I'm pretty sure that the time in the header is accurate, so we use that. I think that the time in snc does not take into account the time zone (that'd explain the 4 or 5 depending on summertime). This time is only used to get the right video so we call this "video time". """

    if sample < sampleStamp[0]:
        s_freq = orig_s_freq
        id0 = 0
    elif sample > sampleStamp[-1]:
        s_freq = orig_s_freq
        id0 = len(sampleStamp) - 1
    else:
        id0 = where(asarray(sampleStamp) <= sample)[0][-1]
        id1 = where(asarray(sampleStamp) >= sample)[0][0]

        if id0 == id1:
            return sampleTime[id0]
        s_freq = ((sampleStamp[id1] - sampleStamp[id0]) /
                  (sampleTime[id1] - sampleTime[id0]).total_seconds())
    time_diff = timedelta(seconds=(sample - sampleStamp[id0]) / s_freq)
    return sampleTime[id0] + time_diff