python怎样索取视频中的音频

python怎样索取视频中的音频

先用pip安置视频处置的库:pip install moviepy

from moviepy.editor import * #导出库

video = VideoFileClip('test.mp4') #视频路途

audio = video.audio

audio.write_audiofile('test.mp3') #导出音频路途

扶助以次方法

extensions_dict = { "mp4": {'type':'video', 'codec':['libx264','libmpeg4', 'aac']},

'ogv': {'type':'video', 'codec':['libtheora']},

'webm': {'type':'video', 'codec':['libvpx']},

'avi': {'type':'video'},

'mov': {'type':'video'},

'ogg': {'type':'audio', 'codec':['libvorbis']},

'mp3': {'type':'audio', 'codec':['libmp3lame']},

'wav': {'type':'audio', 'codec':['pcm_s16le', 'pcm_s24le', 'pcm_s32le']},

'm4a': {'type':'audio', 'codec':['libfdk_aac']}

}

分享到 :

Leave a Reply

Your email address will not be published. Required fields are marked *