将YouTube下载到mp3并使用youtube-dl将元数据(艺术家/歌曲标题)写入mp3文件 [英] Downloading YouTube to mp3 and writing metadata (artist/song title) to mp3 file using youtube-dl

查看:212
本文介绍了将YouTube下载到mp3并使用youtube-dl将元数据(艺术家/歌曲标题)写入mp3文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我仅使用youtube-dl从youtube视频中提取音频. 我想在下载后将元数据(即艺术家姓名和歌曲标题)写入mp3文件.我为实现此目的的尝试从以下代码开始:

I am extracting audio only from youtube videos using youtube-dl. I would like to write the metadata (i.e. Artist Name and Song Title) into the mp3 file after downloading. My attempt to accomplish this starts with this code:

@echo off
set dl=https://www.youtube.com/watch?v=2Y6Nne8RvaA
youtube-dl --metadata-from-title "%(artist)s - %(title)s" --extract-audio --audio-format mp3 -o "%%(title)s.%%(ext)s" --add-metadata %dl%
pause

此代码的输出为:

[youtube] 2Y6Nne8RvaA: Downloading webpage
[youtube] 2Y6Nne8RvaA: Downloading video info webpage
[youtube] 2Y6Nne8RvaA: Extracting video information
[download] Destination: Kungs vs Cookin' on 3 Burners - This Girl.webm
[download] 100% of 3.33MiB in 00:02
[fromtitle] Could not interpret title of video as "(title)s"
[ffmpeg] Adding metadata to 'Kungs vs Cookin' on 3 Burners - This Girl.webm'
[ffmpeg] Destination: Kungs vs Cookin' on 3 Burners - This Girl.mp3
Deleting original file Kungs vs Cookin' on 3 Burners - This Girl.webm (pass -k t
o keep)
Press any key to continue . . .

如您所见,该代码将元数据添加到.webm文件名,而不是添加到.mp3文件.将其写入.webm文件是没有用的,因为此文件在处理完成后将被删除. 我希望将此元数据写入.mp3文件,以便在查看文件夹中的歌曲时看起来像以下内容:

As you can see, the code adds the metadata to .webm filename, but not to the .mp3 file. It is useless to write this to the .webm file because the this file is deleted upon completion of the process. I want this metadata to be written to the .mp3 file so that when I view songs in a folder, it will look like the following:

这种格式对我很有用,因为我可以直接将这些文件输入iTunes,并且元数据将保持完整!

This format is useful to me because I can then directly input these files into iTunes and the metadata will be intact!

我正在运行Windows 7、64位,Python 3.5.

I'm running Windows 7, 64bit, Python 3.5.

推荐答案

该页面甚至没有提供MP3文件:

That page does not even offer an MP3 file:

$ youtube-dl --format mp3 2Y6Nne8RvaA
ERROR: requested format not available

,即使您像尝试的那样尝试结束,它也不起作用:

and even if you try an end-around like you have done, it does not work:


$ youtube-dl --audio-format mp3 2Y6Nne8RvaA
$ ffprobe 'Kungs vs Cookin’ on 3 Burners - This Girl-2Y6Nne8RvaA.mkv'
Input #0, matroska,webm, from 'Kungs vs Cookin’ on 3 Burners - This Girl-2Y6Nne8RvaA.mkv':
  Duration: 00:03:17.48, start: -0.007000, bitrate: 2462 kb/s
    Stream #0:0: Video: h264 (High), yuv420p(tv, bt709, progressive), 1920x1080
    Stream #0:1(eng): Audio: opus, 48000 Hz, stereo (default)

改为使用m4a:

youtube-dl --format m4a 2Y6Nne8RvaA


您正在使用:


You are using:

--extract-audio

何时您可以自行下载音频:

when you can just download the audio by itself:

youtube-dl --format m4a 2Y6Nne8RvaA


您正在使用:


You are using:

https://www.youtube.com/watch?v=2Y6Nne8RvaA

何时可以使用:

2Y6Nne8RvaA


您没有使用:


You are not using:

--youtube-skip-dash-manifest

我可以这样说:

[youtube] 2Y6Nne8RvaA: Downloading video info webpage


即使一切都按照您想要的方式运行,您可能仍然会拥有 由于ID3版本而引起的麻烦:


Even if everything worked the way you want, you would probably still have trouble because of the ID3 version:

FFmpeg元数据未在Windows中显示?

这篇关于将YouTube下载到mp3并使用youtube-dl将元数据(艺术家/歌曲标题)写入mp3文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆