def convert_mp4(video_dir, audio_dir):
'''
Args:
1. video_dir: Directory for all video files
2. audio_dir: Directory where all converted files will be stored.
'''
# Get all file names
video_file_names = sorted(glob.glob(video_dir + "*.mp4"))
# Extract actual names of file, also remove any extensions
video_names = map(lambda x : x.split('/')[-1].split(".")[0], video_file_names)
# Command for converting video to audio
command = "ffmpeg -i " + video_dir + "{0}.mp4 -ab 96k -ar 44100 -vn " + audio_dir + "{0}.wav"
for name in video_names:
subprocess.call(command.format(name), shell=True)
data_preprocessing.py 文件源码
python
阅读 34
收藏 0
点赞 0
评论 0
评论列表
文章目录