Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
downsample sound files using ffmpeg
def is_wav(p):
return os.path.splitext(p)[-1] == '.wav'
def lower_samplerate_cmds(dir_src, samplerate, dir_dst, fpath_exec_script):
paths = fs.gen_paths(dir_src, is_wav)
commands = []
for fpath in paths:
path_dst = os.path.join(dir_dst, os.path.basename(fpath))
cmd = ['ffmpeg', '-i', fpath, '-ac', '2', '-ar', "%d" % (samplerate,), path_dst]
commands = [list2cmdline(cmd) for cmd in commands]
with open(fpath_exec_script, 'w') as f:
for cmd in commands:
f.write('%s\n' % (cmd,))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.