Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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