def af_fade(cutin, cutout, fadein, fadeout):
    """
    Genterate FFmpeg audio fade filter string
    https://ffmpeg.org/ffmpeg-filters.html#afade
    :param cutin: (number) position in the original audio where segment starts
    :param cutout: (number) position in the original audio where segment ends
    :param fadein: (number) length of audio where fade-in applied, in sec
    :param fadeout: (number) length of audio where fade-out applied, in sec
    :return: (str) ffmpeg audio filter string
    """
    a = cutin, fadein, cutout - fadeout, fadeout
    return 'afade=t=in:st={}:d={},afade=t=out:st={}:d={}'.format(*a)
