Created
February 5, 2020 14:36
-
-
Save takiyu/edd825ff10cd3e5359e744b37917cd67 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import glob | |
import os.path as osp | |
import subprocess | |
def extract_mp3(src_filename, dst_filename): | |
cmd = ['ffmpeg', '-i', src_filename, '-acodec', 'libmp3lame', '-ab', | |
'360k', dst_filename] | |
subprocess.call(cmd) | |
if __name__ == '__main__': | |
video_exts = ['mp4', 'webm', 'mkv'] | |
video_filenames = list() | |
for ext in video_exts: | |
video_filenames.extend(glob.glob('*.' + ext)) | |
for video_filename in video_filenames: | |
audio_filename = osp.splitext(video_filename)[0] + '.mp3' | |
extract_mp3(video_filename, audio_filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment