def compute_extended_start_end(start_msec, end_msec, max_end_msec,
                               fraction_extra):
    """Given the start and end time, compute the new_start_msec
        and new_end_msec such that the clip specified by
        them is fraction_extra more than the original clip
        specified by start_msec and end_msec given that
        the calculated bounds are within the bounds of the video

    As an example:
        if end_msec - start_msec is 100 then
        new_end_msec - new_start_msec is 150
        if fraction_extra is 0.5
    """
    duration = end_msec - start_msec
    msec_extra = duration * fraction_extra / 2

    # prevent our adding from going over
    new_end_msec = min(end_msec + msec_extra, max_end_msec)

    # prevent our subtracting from going under
    new_start_msec = max(0, start_msec - msec_extra)
    return new_start_msec, new_end_msec