def image_filter(input_stream, image_stream_index, x, y, t_start, t_end,
                 output_stream):
    """Generate a ffmeg filter specification for an image input.

    Arguments:
    input_stream -- name of the input stream
    image_stream_index -- index of the input image among the -i arguments
    x, y -- position where to overlay the image on the video
    t_start, t_end -- start and end time of the image's appearance
    output_stream -- name of the output stream
    """
    out_str = '' if output_stream is None else ('[' + output_stream + ']')
    return ('[' + input_stream + '][' + str(image_stream_index) + ':v] '
            'overlay=' + str(x) + ':' + str(y) + ':'
            'enable=\'between(t,' + str(t_start) + ','
                + str(t_end) + ')\' ' +
            out_str)