8

我想只播放来自 youtube 的声音。我需要这个用于IOS,但其他人可以。我在stackoverflow上搜索过,但找不到。因为我不想使用其他软件,所以我想直接通过代码仅流式传输 youtube 视频的声音。它也应该在后台工作。

4

7 回答 7

7

Flashgot (for Firefox) has a way to download only the audio of a Youtube video. It exposes links to the audio that looks like this:

https://r3---sn-p5qlsu7d.googlevideo.com/videoplayback?id=887ce37c617a3225&itag=141&source=youtube&requiressl=yes&gcr=ca&ratebypass=yes&mime=audio%2Fmp4&gir=yes&clen=4012348&lmt=1409362978343745&dur=125.828&signature=0A00B9B16BB6EF3192DF33EEF9B2AB67F66F501F.0B649D407144B914A7CC7BE00E795B5BD1B9D932&upn=VFAbXgDGSU8&key=cms1&fexp=900718%2C924231%2C924637%2C927622%2C930809%2C931354%2C932404%2C9405454%2C941004%2C943917%2C945066%2C947209%2C947218%2C948124%2C952302%2C952605%2C952901%2C955301%2C957103%2C957105%2C957201&sver=3&ip=24.235.37.181&ipbits=0&expire=1419930614&sparams=clen,dur,expire,gcr,gir,id,ip,ipbits,itag,lmt,mime,mm,ms,mv,ratebypass,requiressl,source&cmbypass=yes&req_id=3eb2c618c54ca3ee&redirect_counter=2&cms_redirect=yes&mm=26&ms=tsu&mt=1419909012&mv=m

OK, so that is a very big link. This is the same link dissected into pieces:

https://r3---sn-p5qlsu7d.googlevideo.com/videoplayback?id=887ce37c617a3225
&itag=141
&source=youtube
&requiressl=yes
&gcr=ca
&ratebypass=yes
&mime=audio/mp4 #Here's where audio only is specified.
&gir=yes
&clen=4012348
&lmt=1409362978343745
&dur=125.828
&signature=0A00B9B16BB6EF3192DF33EEF9B2AB67F66F501F.0B649D407144B914A7CC7BE00E795B5BD1B9D932
&upn=VFAbXgDGSU8
&key=cms1
&fexp=900718,924231,924637,927622,930809,931354,932404,9405454,941004,943917,945066,947209,947218,948124,952302,952605,952901,955301,957103,957105,957201
&sver=3
&ip=24.235.37.181 #Oh, look. My IP address.
&ipbits=0
&expire=1419930614
&sparams=clen,dur,expire,gcr,gir,id,ip,ipbits,itag,lmt,mime,mm,ms,mv,ratebypass,requiressl,source
&cmbypass=yes
&req_id=3eb2c618c54ca3ee
&redirect_counter=2
&cms_redirect=yes
&mm=26
&ms=tsu
&mt=1419909012
&mv=m

Very interesting. This enables Flashgot to download only the audio and skip the video, thus saving bandwidth. I'm missing details, like how Flashgot created this link, but if Flashgot has a way to do it, it stands to reason that other HTTP clients could do it too.

于 2014-12-30T03:39:21.100 回答
3

根据Youtube API 博客文章,在 iOS 上播放 youtube 的唯一选择是链接到视频(并让内部 YouTube 应用播放视频),或者从 UIWebView 链接并从那里播放。 不支持纯音频播放

于 2012-04-23T15:04:56.987 回答
2

你不能。您从 youtube 收到的数据流包括视频/音频流。

你如何处理数据,这取决于你。这个线程有关于这个主题的有趣信息。

于 2012-04-23T15:01:58.237 回答
1

我会使用 MPMoviePlayerController 并隐藏它的视图。

于 2012-04-23T14:56:40.050 回答
1

使用 Audacity 软件,您可以从任何来源录制计算机上播放的音频。由于 Audacity 是开源的,您可以找到开源浏览器,您可以将它们组合起来并从 youtube 获取音频。当然它的工作量很大,但我只是说它可能与其他人不同。

于 2014-05-25T11:58:44.430 回答
1

音频视频单独的流。这是在 mp4 到 flash 转换中的默认设置。

您可以获取 Flash 格式的组合流或 mp4 格式的单独流。

示例:[耳机立体声测试 (HD)][youtube.com/watch?v=ZjAQylVPU3I]

包含

[闪流][youtube.com/v/ZjAQylVPU3I]

包含 mp4格式的音频流视频流的组合。

*很抱歉,这些链接将不起作用,因为它们是根据 ip 、 expire data 和其他东西定制的。

为了获得这些链接,我使用 uBlock origin for chrome,因为它具有记录器功能,显示与服务器建立的所有连接。搜索:mime=video,您可以看到所有链接,然后删除范围以获得完整长度。与 mime=audio 相同,您也可以将其用于其他 Flash 播放器中的流,但这违反了服务条款

于 2016-06-19T23:20:43.190 回答
1

在 Linux 中:

  • mps-youtube一个 CLI 解决方案。更多细节在这里

  • 如果在没有视频的情况下开始VLC也可以做到这一点 - 更多信息在这里

  • mplayer可以与命令一起使用mplayer -novideo URL

  • mpv可以与命令一起使用mpv --no-video URL

  • Youtube Viewer ,一个 CLI 视频播放器也可以使用,如此所示。

跨平台解决方案:

另一个答案所示 ,Firefox 的 Flashgot 插件可以识别以下载 Youtube 视频的音频。它将显示每个视频的可用流列表。

这个想法是在外部播放器中启动 youtube 流,但是通过将外部播放器添加为 Flashgot“下载器”(如这里),然后在启动 youtube 后,能够在 Firefox 中仅选择带有 Flashgot 插件的音频流Firefox 中的视频,使用 Flashgot 通过转到“可用格式/DASH(单独的音频和视频轨道)”来仅播放音频流

[在此处输入图像描述

并选择特定的音轨。

[在此处输入图像描述

可以在 Flashgot 中分配多媒体播放器,而不是像 VLC 或 SMPlayer 这样的下载器,因为大多数视频播放器似乎都能完成这项工作(在 Linux 中;对于 Windows,请参见下面的更新);甚至像 Clementine 这样的音频播放器,尽管有些音频播放器可能无法正常工作。

它将在几秒钟后开始,一些玩家比其他人多。Linux 中最快的似乎是SMPlayer

更新

  • Flashgot 必须是最新的。

  • 在 Windows 中,Flashgot 似乎在与上图不同的位置显示一些音频流,这已经在第一个列表中(在 DASH 列表之前)。SMPlayer 是最好的 AFAICT。VLC 有效,但不适用于 Flashgot 列出的所有音频流。Clementine、Foobar2000 和 XMPlay 失败。这可能是一个整体的 Windows 编解码器问题。MPC-HC 启动但不能正确缓冲并在它应该之前停止很长时间。

于 2015-09-16T16:10:06.003 回答