From: Mauro Scomparin Date: Mon, 31 Aug 2020 16:55:58 +0000 (+0200) Subject: first time i run it X-Git-Url: https://git.scompo.it/?a=commitdiff_plain;ds=sidebyside;p=record-splitter.git first time i run it --- 988e48aa43662cae94df80f2d0440e919c18a5c8 diff --git a/splitter.py b/splitter.py new file mode 100644 index 0000000..e635793 --- /dev/null +++ b/splitter.py @@ -0,0 +1,34 @@ +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() + diff --git a/test/in.txt b/test/in.txt new file mode 100644 index 0000000..4f7645c --- /dev/null +++ b/test/in.txt @@ -0,0 +1,4 @@ +00:00 01:00 out 1 +01:00 02:00 out 2 +02:00 03:00 out 3 +