def split_duration(total_duration, target_duration, split_last=False):
    """
    Splits total_duration into parts
    :param total_duration: total duration of file
    :param target_duration: target duration of parts
    :param split_last: if True, last part may be less than others, otherwise it can be more that others
    :return: array of object with fields
        - start - start of part
        - end - end of part
        - duration - duration of part
        Note that the last part's duration will probably be not equal target_duration
    """
    res = []
    start = 0
    pre_end = total_duration - target_duration * 2
    total_count = total_duration // target_duration
    if split_last:
        pre_end = pre_end + target_duration
    while start < pre_end:
        res.append({'start': start, 'end': start + target_duration, 'duration': target_duration})
        start = start + target_duration
    if split_last:
        res.append({'start': start, 'end': start + target_duration, 'duration': target_duration})
        res.append({'start': start + target_duration, 'end': total_duration,
                    'duration': total_duration - target_duration * (total_count - 1)})
    else:
        res.append({'start': start, 'end': total_duration,
                    'duration': total_duration - target_duration * (total_count - 2)})
    return res