def extract_audio_with_spd(src, dst, ss, to, spd=1.0):
    fname = os.path.splitext(os.path.basename(dst))[0]
    tempfile1 = os.path.join(settings['tempdir'],
                             '~{}.{}'.format(fname, settings['v_container']).
                             lower())
    call = [
        settings['avutil'],
        '-loglevel', settings['av_loglevel'],
        '-y',
        '-i', src,
        '-ss', str(ss/1000.0),  # ss in ms
        '-to', str(to/1000.0),  # to in ms
        '-map_metadata', '-1',
        '-map_chapters', '-1',
        '-vn',
        '-sn']
    if settings['ca'] == 'aac':
        call.extend(['-strict', '-2'])  # aac is an experimental encoder so
        # -strict experimental or -strict 2 is req
    call.extend([
        '-c:a', settings['ca'],
        '-b:a', settings['ba'],
        tempfile1])
    if subprocess.call(call) == 1:
        raise RuntimeError
    # change spd using atempo filter
    tempfile2 = os.path.join(settings['tempdir'],
                             '~{}.{}x.{}'.format(fname, spd,
                                                 settings['a_container']))
    atempo_chain = []  # chain atempo filts to workaround val limitation
    for f in mk_product_chain(spd, 0.5, 2.0):
        atempo_chain.append('atempo={}'.format(f))
    call = [
        settings['avutil'],
        '-loglevel', settings['av_loglevel'],
        '-y',
        '-i', tempfile1,
        '-filter:a', ','.join(atempo_chain)]
    if settings['ca'] == 'aac':
        call.extend(['-strict', '-2'])
    call.extend([
        '-c:a', settings['ca'],
        '-b:a', settings['ba'],
        tempfile2])
    if subprocess.call(call) == 1:
        raise RuntimeError
    os.remove(tempfile1)
    shutil.move(tempfile2, dst)
dataset/ETHPy150Open dthpham/butterflow/butterflow/mux.py/extract_audio_with_spd/original