def get_vf_res_scale_down(width: int, height: int, res_limit='FHD', vf: str = '') -> str:
    """generate 'scale=<w>:<h>' value for ffmpeg `vf` option, to scale down the given resolution
    return empty str if the given resolution is enough low thus scaling is not needed"""
    d = {'FHD': (1920, 1080), 'HD': (1280, 720), 'qHD': (960, 540), 'QHD': (2560, 1440), '4K': (3840, 2160),
         '360p': (640, 360)}
    auto_calc = -2
    if not res_limit:
        return vf
    tgt_long, tgt_short = d[res_limit]
    long = max((width, height))
    short = min((width, height))
    if long <= tgt_long and short <= tgt_short:
        return vf
    ratio = short / long
    tgt_ratio = tgt_short / tgt_long
    thin = False if ratio > tgt_ratio else True
    portrait = True if height > width else False
    baseline = tgt_long if thin else tgt_short
    res_scale = 'scale=' + (
        f'{baseline}:{auto_calc}' if thin ^ portrait
        else f'{auto_calc}:{baseline}'
    )
    return f'{res_scale},{vf}' if vf else res_scale