Skip to content

Instantly share code, notes, and snippets.

@kylemcdonald
Created May 15, 2022 07:58
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 kylemcdonald/4db6c88ef58fa93a8a72d824aa5639cf to your computer and use it in GitHub Desktop.
Save kylemcdonald/4db6c88ef58fa93a8a72d824aa5639cf to your computer and use it in GitHub Desktop.
Split an audio file into multiple files given a list of timestamps exported from timestamps.me out of an Ableton set.
import subprocess
track_fn = 'audio.wav'
timestamps_fn = 'timestamps.csv'
with open(timestamps_fn) as f:
lines = f.read().splitlines()
lines = [e.split(',')[2] for e in lines]
cmd_string = 'ffmpeg -hide_banner -loglevel error -i {tr} -acodec copy -ss {st} -to {en} {nm}'
for i,(a,b) in enumerate(zip(lines,lines[1:])):
nm = str(i).zfill(2) + '-' + track_fn
cmd = cmd_string.format(tr=track_fn, st=a, en=b, nm=nm)
print(cmd)
subprocess.call(cmd, shell=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment