【问题标题】:Downloading YouTube to mp3 and writing metadata (artist/song title) to mp3 file using youtube-dl使用 youtube-dl 将 YouTube 下载到 mp3 并将元数据(艺术家/歌曲标题)写入 mp3 文件
【发布时间】:2017-04-24 08:52:57
【问题描述】:

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

@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 文件,这样当我查看文件夹中的歌曲时,它会如下所示:

这种格式对我很有用,因为我可以直接将这些文件输入到 iTunes 中,元数据将是完整的!

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

【问题讨论】:

    标签: metadata mp3 extract webm youtube-dl


    【解决方案1】:

    该页面甚至不提供 MP3 文件:

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

    即使你像以前那样尝试结束,它也不起作用:

    $ youtube-dl --audio-format mp3 2Y6Nne8RvaA $ ffprobe 'Kungs vs Cookin' on 3 Burners - This Girl-2Y6Nne8RvaA.mkv' 输入 #0,matroska,webm,来自 3 个燃烧器上的“Kungs vs Cookin” - This Girl-2Y6Nne8RvaA.mkv': 时长:00:03:17.48,开始:-0.007000,比特率:2462 kb/s 流 #0:0:视频:h264(高)、yuv420p(电视、bt709、渐进式)、1920x1080 Stream #0:1(eng):音频:opus,48000 Hz,立体声(默认)

    改用 m4a:

    youtube-dl --format m4a 2Y6Nne8RvaA
    

    您正在使用:

    --extract-audio
    

    当您可以自己下载音频时:

    youtube-dl --format m4a 2Y6Nne8RvaA
    

    您正在使用:

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

    当你可以使用时:

    2Y6Nne8RvaA
    

    你没有使用:

    --youtube-skip-dash-manifest
    

    因为这条额外的行,我可以判断:

    [youtube] 2Y6Nne8RvaA: Downloading video info webpage
    

    即使一切如你所愿,你可能仍然有 ID3版本的麻烦:

    FFmpeg metadata not showing in Windows?

    【讨论】:

    • 感谢您的来信。正如你所知道的,我对此很陌生,而且我每天都在学习更多。您的评论对我很有帮助。
    猜你喜欢
    • 2015-08-03
    • 2017-04-25
    • 1970-01-01
    • 1970-01-01
    • 2011-05-22
    • 2022-08-17
    • 1970-01-01
    • 2012-02-25
    • 1970-01-01
    相关资源
    最近更新 更多