File size: 667 Bytes
029074a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import os
from concurrent.futures import ThreadPoolExecutor
from moviepy.editor import AudioFileClip
video_dir = "./video_data/"
audio_dir = "./raw_audio/"
filelist = list(os.walk(video_dir))[0][2]
def generate_infos():
videos = []
for file in filelist:
if file.endswith(".mp4"):
videos.append(file)
return videos
def clip_file(file):
my_audio_clip = AudioFileClip(video_dir + file)
my_audio_clip.write_audiofile(audio_dir + file.rstrip(".mp4") + ".wav")
if __name__ == "__main__":
infos = generate_infos()
with ThreadPoolExecutor(max_workers=os.cpu_count()) as executor:
executor.map(clip_file, infos)
|