def generate_filename(in_path, out_dir, bitrate, encoder):
    """
    Create a new filename based on the original video file and test bitrate.

    Parameters
    ----------
    in_path : str
        Full path of input video.
    out_dir : str
        Directory of output video.
    bitrate : int
        Video bitrate in kbit/s.
    encoder : str
        Encoder for FFmpeg to use.

    Returns
    -------
    out_path : str
        Full path of new output video.
    """
    if in_path.count('.') >= 2:
        raise Exception('Filename has multiple full stops')
    out_video = in_path.split(
        '/')[-1].replace('.', f'_{encoder}_{int(bitrate)}.')
    out_path = out_dir + out_video
    return out_path