Skip to content

Instantly share code, notes, and snippets.

@rdkls
Last active May 3, 2021 13:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rdkls/4999262 to your computer and use it in GitHub Desktop.
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
#!/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])
Copy link

ghost commented May 12, 2020

how to select codes like "-codec copy"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment