Skip to content

Instantly share code, notes, and snippets.

@fredmajor
Created February 13, 2019 16:39
Show Gist options
  • Save fredmajor/651c4490151f3954d811a103de4733f4 to your computer and use it in GitHub Desktop.
Save fredmajor/651c4490151f3954d811a103de4733f4 to your computer and use it in GitHub Desktop.
#!/usr/local/bin/python3
import glob
import subprocess
import argparse
parser=argparse.ArgumentParser()
parser.add_argument('out_file', type=str, help='the output audio file', default='out.mp3')
args = parser.parse_args()
args = args.__dict__
files=glob.glob("*.mp3")
if not files:
print('No input files detected. Will exit.')
exit(1)
files.sort()
files_str = '|'.join(files)
files_arg = 'concat:{}'.format(files_str)
cmd = 'ffmpeg -i "{}" -acodec copy {}'.format(files_arg, args['out_file'])
print(cmd)
result = subprocess.run(cmd, shell=True)
print('done')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment