Created
May 15, 2022 07:58
-
-
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.
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
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