java 从 YouTube 视频中获取音频

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4368326/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 06:04:07  来源:igfitidea点击:

Take the audio from a youtube video

javaaudioyoutube-api

提问by papafe

Is it possible to retrieve only the audio from a youtube video using the java youtube api?

是否可以使用 java youtube api 仅从 youtube 视频中检索音频?

回答by Mark Mayo

Very similar to How do I programmatically extract the audio from a YouTube video?.

非常类似于如何编程方式从 YouTube 视频中提取音频?.

The top answer there is:

最佳答案是:

Writing an application for this might be overkill. Existing tools already do a pretty good job, and it's hard to beat their simplicity:

wget http://www.youtube.com/get_video.php?video_id=...

| ffmpeg -i - audio.mp3

All done!

If your application needs to do something special with the audio afterwards, it would make sense to write an app for that part. But for just getting the audio out, shelling out to ffmpeg will be a lot easier.

为此编写应用程序可能有点矫枉过正。现有的工具已经做得很好,而且它们的简单性很难被打败:

wget http://www.youtube.com/get_video.php?video_id=...

| ffmpeg -i - 音频.mp3

全做完了!

如果您的应用程序之后需要对音频做一些特别的事情,那么为该部分编写一个应用程序是有意义的。但是为了将音频输出,转至 ffmpeg 会容易得多。

Kudos to John Feminellafor the answer.

荣誉对约翰Feminella的答案。

回答by head_thrash

sudo apt-get install youtube-dl ffmpeg libavcodec-extra-53 libav-tools

youtube-dl -x --audio-format mp3 --audio-quality 4 http://youtu.be/oRJ0FaOIIbM