commit 8e6d9e50bca97d68ac80497bdfc13ec3d5b7bddf Author: Zev Averbach Date: Thu Oct 7 21:33:45 2021 +0200 first diff --git a/app/extract_audio b/app/extract_audio new file mode 100755 index 0000000..65b4d9b --- /dev/null +++ b/app/extract_audio @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 + +from pathlib import Path +from subprocess import check_output +from sys import argv as args +import threading + + +def extract_audio(dir_, fp): + return check_output(f"ffmpeg -i {fp} -vn -acodec copy {dir_}{fp.stem}.m4a", shell=True) + + +def main(dir_): + threads = [] + for fp in Path(dir_).iterdir(): + a = threading.Thread( + target=extract_audio, + args=( + dir_, + fp, + ), + ) + threads.append(a) + a.start() + for thread in threads: + thread.join() + + +if __name__ == "__main__": + dirpath = args[1] + main(dirpath)