+import subprocess
+import shlex
+import re
+import sys
+
+command_template = "ffmpeg -i \"{}\" -ss \"{}\" -to \"{}\" -c copy \"{}\""
+
+def main() :
+ print("Audio splitter")
+ audio_file=sys.argv[2]
+ start="00:00:00"
+ track_file=sys.argv[1]
+ count = 0
+ with open(track_file) as f:
+ for line in f:
+ line_clean = line.rsplit("\n")[0]
+ if line_clean != "":
+ count = count + 1
+ pieces = line_clean.split("\t")
+ start= pieces[0]
+ stop=pieces[1]
+ output_file=str(count).zfill(2) + "-" + pieces[2] + ".ogg"
+ command = command_template.format(audio_file, start, stop, output_file)
+ # command="echo hello"
+ print("Running command: {}".format(command))
+ split_command = shlex.split(command)
+ process=subprocess.Popen(split_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = process.communicate()
+ print(stdout.decode())
+ print(stderr.decode())
+
+if __name__ == "__main__":
+ main()
+