e3a941bad2
Prevent stripping of the "4" character at the end of the random number.
28 lines
665 B
Python
28 lines
665 B
Python
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)
|