有几种方法可以从Youtube下载MP3曲目,例如Linux中的Web应用程序,Windows应用程序和命令行工具。Youtube-DL 是市场上最好的工具之一,可以从youtube下载曲目。它是用 Python编程语言开发的。该程序几乎可以在所有Linux发行版中使用。如果您还没有听说过此工具,那么本文适合您。
要安装youtube-DL,请使用以下命令-
$ sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
样本输出应如下所示–
--2016-03-08 11:41:21-- https://yt-dl.org/downloads/latest/youtube-dlResolving yt-dl.org (yt-dl.org)... 95.143.172.170, 2001:1a50:11:0:5f:8f:acaa:177 Connecting to yt-dl.org (yt-dl.org)|95.143.172.170|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://yt-dl.org/downloads/2016.03.06/youtube-dl [following] --2016-03-08 11:41:23-- https://yt-dl.org/downloads/2016.03.06/youtube-dlConnecting to yt-dl.org (yt-dl.org)|95.143.172.170|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 1133512 (1.1M) [application/octet-stream] Saving to: ‘/usr/local/bin/youtube-dl’ 100%[======================================>] 11,33,512 218KB/s in 6.2s 2016-03-08 11:41:30 (180 KB/s) - ‘/usr/local/bin/youtube-dl’ saved [1133512/1133512]
更改youtube-dl目录权限以访问youtube-dl命令。要更改目录权限,请使用以下命令–
$ sudo chmod a+rx /usr/local/bin/youtube-dl
要获取有关youtube-DL的更多信息,请使用以下命令-
# youtube-dl --help
上面的命令应要求具有root权限,其输出应如下所示–
Options: -h, --help Print this help text and exit --version Print program version and exit -U, --update Update this program to latest version. Make sure that you have sufficient permissions (run with sudo if needed) -i, --ignore-errors Continue on download errors, for example to skip unavailable videos in a playlist --abort-on-error Abort downloading of further videos (in the playlist or the command line) if an error occurs --dump-user-agent Display the current browser identification --list-extractors List all supported extractors --extractor-descriptions Output descriptions of all supported extractors --force-generic-extractor Force extraction to use the generic extractor --default-search PREFIX Use this prefix for unqualified URLs. For example "gvsearch2:" downloads two videos from google videos for youtube-dl "large apple". Use the value "auto" to let youtube-dl guess ("auto_warning" to emit a warning when guessing). "error" just throws an error. The default value "fixup_error" repairs broken URLs, but emits an error if this is not possible instead of searching. --ignore-config Do not read configuration files. When given in the global configuration file /etc /youtube-dl.conf: Do not read the user configuration in ~/.config/youtube- dl/config (%APPDATA%/youtube-dl/config.txt on Windows) --flat-playlist Do not extract the videos of a playlist, only list them. --mark-watched Mark videos watched (YouTube only) --no-mark-watched Do not mark videos watched (YouTube only) --no-color Do not emit color codes in output .........................
要将音乐转换为不同的音频格式,youtube-dl需要ffmpeg或avconv以及其帮助程序ffprobe或avprobe。
要安装其中之一,请使用以下命令-
$ sudo apt-get install ffmpeg
样本输出应如下所示–
Building dependency tree Reading state information... Done ffmpeg is already the newest version. The following packages were automatically installed and are no longer required: gcc-4.8-base:i386 libasn1-8-heimdal:i386 libasound2:i386 libasound2-plugins:i386 libasyncns0:i386 libavahi-client3:i386 libavahi-common-data:i386 libavahi-common3:i386 libbit-vector-perl libcapi20-3:i386 libcarp-clan-perl libclass-method-modifiers-perl libcups2:i386 libdata-random-perl libdate-calc-perl libdate-calc-xs-perl libdrm-amdgpu1:i386 libdrm-intel1:i386 libdrm-nouveau2:i386 libdrm-radeon1:i386 libedit2:i386 libelf1:i386 libexif12:i386 libexpat1:i386 libffi6:i386 libflac8:i386 libfontconfig1:i386 libfreetype6:i386 libgcrypt11:i386 libgd-perl libgd3:i386 libgif4:i386 libgl1-mesa-dri-lts-wily:i386 libgl1-mesa-glx-lts-wily:i386 libglapi-mesa-lts-wily:i386 libglib2.0-0:i386 libglu1-mesa:i386 libgnome2-gconf-perl libgnutls26:i386 libgpg-error0:i386 libgphoto2-6:i386 libgphoto2-port10:i386 libgssapi-krb5-2:i386 libgssapi3-heimdal:i386 libgstreamer-plugins-base0.10-0:i386 libgstreamer0.10-0:i386 libhcrypto4-heimdal:i386 libheimbase1-heimdal:i386 libheimntlm0-heimdal:i386 libhx509-5-heimdal:i386 libice6:i386 libieee1284-3:i386 ..........................
要下载MP3曲目,请使用以下命令-
$ youtube-dl -x --audio-format mp3 --prefer-ffmpeg https://www.youtube.com/watch?v=jwD4AEVBL6Q
样本输出应如下所示–
[youtube] jwD4AEVBL6Q: Downloading webpage [youtube] jwD4AEVBL6Q: Downloading video info webpage [youtube] jwD4AEVBL6Q: Extracting video information [youtube] jwD4AEVBL6Q: Downloading MPD manifest [download] Destination: Bad Style - Time back-jwD4AEVBL6Q.m4a [download] 100% of 7.45MiB in 00:08 [ffmpeg] Correcting container in "Bad Style - Time back-jwD4AEVBL6Q.m4a" [ffmpeg] Destination: Bad Style - Time back-jwD4AEVBL6Q.mp3 Deleting original file Bad Style - Time back-jwD4AEVBL6Q.m4a (pass -k to keep)
上面的命令使用以下两个选项–
–extract-audio(简短选项-x) –将视频文件转换为纯音频文件。–audio-format –指定文件下载的音频格式。支持的音频格式为“最佳”,“ aac”,“ vorbis”,“ mp3”,“ m4a”,“ opus”或“ wav”;默认设置为“最佳”。
要从播放列表下载多个文件,请使用以下命令-
[youtube:playlist] PL9LUD5Kp855InMnKTaRy3LH3kTIYJyBzs: Downloading webpage [download] Downloading playlist: Top Tracks - Imagine Dragons [youtube:playlist] playlist Top Tracks - Imagine Dragons: Downloading 5 videos [download] Downloading video 1 of 5 [youtube] mWRsgZuwf_8: Downloading webpage [youtube] mWRsgZuwf_8: Downloading video info webpage [youtube] mWRsgZuwf_8: Extracting video information [youtube] mWRsgZuwf_8: Downloading js player en_US-vflteKQR7 [youtube] mWRsgZuwf_8: Downloading js player en_US-vflteKQR7 [download] Destination: Imagine Dragons - Demons (Official)-mWRsgZuwf_8.webm [download] 100% of 3.38MiB in 00:06 [ffmpeg] Destination: Imagine Dragons - Demons (Official)-mWRsgZuwf_8.mp3 Deleting original file Imagine Dragons - Demons (Official)-mWRsgZuwf_8.webm (pass -k to keep) [download] Downloading video 2 of 5 [youtube] ktvTqknDobU: Downloading webpage [youtube] ktvTqknDobU: Downloading video info webpage [youtube] ktvTqknDobU: Extracting video information [youtube] ktvTqknDobU: Downloading js player en_US-vflteKQR7 [download] Destination: Imagine Dragons - Radioactive-ktvTqknDobU.webm [download] 100% of 3.81MiB in 00:01 [ffmpeg] Destination: Imagine Dragons - Radioactive-ktvTqknDobU.mp3 Deleting original file Imagine Dragons - Radioactive-ktvTqknDobU.webm (pass -k to keep) [download] Downloading video 3 of 5 [youtube] sENM2wA_FTg: Downloading webpage [youtube] sENM2wA_FTg: Downloading video info webpage [youtube] sENM2wA_FTg: Extracting video information [download] Destination: Imagine Dragons - It's Time-sENM2wA_FTg.webm [download] 100% of 3.81MiB in 00:01 [ffmpeg] Destination: Imagine Dragons - It's Time-sENM2wA_FTg.mp3 Deleting original file Imagine Dragons - It's Time-sENM2wA_FTg.webm (pass -k to keep) [download] Downloading video 4 of 5 [youtube] w5tWYmIOWGk: Downloading webpage [youtube] w5tWYmIOWGk: Downloading video info webpage [youtube] w5tWYmIOWGk: Extracting video information [download] Destination: Imagine Dragons - On Top Of The World (Official Music Video)-w5tWYmIOWGk.webm [download] 100% of 3.92MiB in 00:03 [ffmpeg] Destination: Imagine Dragons - On Top Of The World (Official Music Video)-w5tWYmIOWGk.mp3 Deleting original file Imagine Dragons - On Top Of The World (Official Music Video)-w5tWYmIOWGk.webm (pass -k to keep) [download] Downloading video 5 of 5 [youtube] VP9I8ZUwKpc: Downloading webpage [youtube] VP9I8ZUwKpc: Downloading video info webpage [youtube] VP9I8ZUwKpc: Extracting video information [download] Destination: Imagine Dragons - Warriors (Lyric Video)-VP9I8ZUwKpc.webm [download] 100% of 2.57MiB in 00:01 [ffmpeg] Destination: Imagine Dragons - Warriors (Lyric Video)-VP9I8ZUwKpc.mp3 Deleting original file Imagine Dragons - Warriors (Lyric Video)-VP9I8ZUwKpc.webm (pass -k to keep) [download] Finished downloading playlist: Top Tracks - Imagine Dragons
恭喜你!现在,您知道“如何使用YouTube-DL从YouTube视频下载MP3曲目”。在下一篇Linux文章中,我们将学习有关这些命令类型的更多信息。继续阅读!
编辑:经过一些测试后,这里是关于这个主题的一些附加信息。我试着从互联网上获取音频的视频只是一个示例mp4文件: http://download.wavetlan.com/svv/media/http/mp4/convertedfiles/mediaCoder/mediaCoder_test6_1m9s_xvid_vbr_306kbps_320x240_25fps_mpeg1layer3_cbr_3
问题内容: 有几篇关于使用来从文章,但没有一篇是具体的或有用的。我想知道从Python脚本执行此操作的最佳方法是什么。 例如,这是下载视频的README示例: 显然,如果您只关心音频,则不希望下载整个视频… 在YouTube的-DL源仅仅是如此的帮助(即不太)。 任何建议如何编写脚本? 问题答案: 阅读开发者说明中的修改示例: 如果可能/受支持,它将下载音频文件。如果文件还不是mp3,则使用ffm
问题内容: new YouTubePageStreamUriGetter().execute( 该代码不起作用 问题答案: 编辑3 您可以使用Lib:https : //github.com/HaarigerHarald/android- youtubeExtractor 例如: 他们使用以下方法解密Signature: 现在,使用此库, 高质量视频会 丢失 音频,因此我将MediaMuxer用于
问题内容: 我知道有上百万种方法可以从youtube下载视频,然后将其转换为音频或对其进行进一步处理。但是最近,我很惊讶地在Mac上看到一个名为YoutubeToMp3的应用程序实际显示“正在跳过X mb视频”,并且据说只从视频中下载音频,而无需使用bandwith下载整个视频然后进行转换。我想知道这是否真的正确,并且根本不可能,因为我找不到任何方法可以做到这一点。你有什么想法 ? 编辑:经过一些
我只从使用的youtube视频中提取音频。我想在下载后将元数据(即艺人名称和歌名)写入mp3文件。我尝试从以下代码开始: 这段代码的输出是: 如您所见,代码将元数据添加到文件名中,而不是添加到文件中。将其写入文件是无用的,因为该文件在进程完成后会被删除。我希望将此元数据写入文件,以便在查看文件夹中的歌曲时,它将如下所示: 这种格式对我很有用,因为我可以直接输入这些文件到iTunes,元数据将是完整
问题内容: 我想使用Java从YouTube网址获取v = id YouTube网址格式示例: &a=GxdCwVVULXctT2lYDEPllDR0LRTutYfW ](http://www.youtube.com/watch?v=u8nQa1cJyX8&a=GxdCwVVULXctT2lYDEPllDR0LRTutYfW) //www.youtube.com/watch?v=u8nQa1cJy