first
This commit is contained in:
31
app/extract_audio
Executable file
31
app/extract_audio
Executable file
@@ -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)
|
||||
Reference in New Issue
Block a user