如何重命名将要使用以下程序下载的.wav文件


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,而不是Smile Please World JpjEwiseVIo.wav关于高中生英语教育重要性的演讲。请帮助我解决这个问题。

您只需在ydl_opts中添加"outtmpl"即可。如果你喜欢,也可以使用一个变量:

name = 'audio1'
ydl_opts = {
'outtmpl':name+'.%(ext)s',
...
}

相关内容

最新更新