编程语言
首页 > 编程语言> > [ Python ] 用 Python 提取视频中的音频,并剪辑

[ Python ] 用 Python 提取视频中的音频,并剪辑

作者:互联网

https://www.cnblogs.com/yeungchie/

提取音频

import moviepy.editor as m

audio = m.AudioFileClip(r'xxx.mp4')
audio.write_audiofile(r'xxx.mp3')

读入音频

from pydub import AudioSegment as a
sound = a.from_mp3(r'xxx.mp3')

截取音频

s7 = sound[:7*1000]
s5_29 = sound[(5*60+29)*1000:]

保存音频

s7.export(r's7.mp3')

标签:sound,Python,音频,xxx,s7,剪辑,mp3,截取
来源: https://www.cnblogs.com/yeungchie/p/16464628.html