Skip to content

Instantly share code, notes, and snippets.

@sljeff
Created November 25, 2016 02:44
Show Gist options
  • Save sljeff/64e035087c744342a9237d7f19104093 to your computer and use it in GitHub Desktop.
Save sljeff/64e035087c744342a9237d7f19104093 to your computer and use it in GitHub Desktop.
python. convert video to audio.
# coding: utf-8
import moviepy.editor as mp
import sys
def convert(video_file_name, audio_file_name=None):
if audio_file_name is None:
audio_file_name = video_file_name + '.mp3'
try:
clip = mp.VideoFileClip(video_file_name)
clip.audio.write_audiofile(audio_file_name)
print('success')
except Exception as e:
print(e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment