Last active
May 26, 2016 08:44
-
-
Save kashefy/9ec6204356583e42a11398d7300be2ed to your computer and use it in GitHub Desktop.
downsample sound files using ffmpeg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.append(cmd) | |
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