Last active
May 3, 2021 13:28
-
-
Save rdkls/4999262 to your computer and use it in GitHub Desktop.
python script to recursively convert all files in a source directory to a target directory using ffmpeg
This file contains 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
#!/usr/bin/python | |
import os | |
import pprint | |
import subprocess | |
src_dir = '/Volumes/Untitled CD' | |
dst_dir = '/tmp/cd' | |
for root, dirs, files in os.walk(src_dir): | |
for f in files: | |
prefix, suffix = os.path.splitext(f) | |
if '.m4a' == suffix: | |
abspath_in = root + '/' + f | |
dir_out = root.replace(src_dir, dst_dir) | |
if not os.path.exists(dir_out): | |
os.makedirs(dir_out) | |
abspath_out = dir_out + '/' + prefix + '.mp3' | |
subprocess.call(['ffmpeg', '-i', abspath_in, '-y', abspath_out]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how to select codes like "-codec copy"