from __future__ import unicode_literals
import youtube_dl
ydl_opts = {
'format': 'bestaudio/best',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'wav',
'preferredquality': '192'
}],
'postprocessor_args': [
'-ar', '16000'
],
'prefer_ffmpeg': True,
'keepvideo': True
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download(['https://www.youtube.com/watch?v=JpjEwIceVIo'])
输出:
[youtube] JpjEwIceVIo: Downloading webpage
[download] Speech on Importance of Education in English for Higher Secondary students by Smile Please World-JpjEwIceVIo.webm has already been downloaded
[download] 100% of 1.69MiB
[ffmpeg] Destination: Speech on Importance of Education in English for Higher Secondary students by Smile Please World-JpjEwIceVIo.wav
我想将文件名改为audio1.wav,而不是关于微笑世界对高中生英语教育重要性的演讲-JpjEwIceVIo.wav。请帮我解决这个问题
您只需在ydl_选项中添加“outtmpl”。如果愿意,也可以使用变量:
相关问题 更多 >
编程相关推荐