I would like to stream only sound from youtube. I need this for IOS but others can be ok. I have searched on stackoverflow but I couldn't find. Because I don't want to use another software, I want to directly stream only sound of youtube video by code. Also It should work on background.
我想只从youtube传输声音。我需要这个用于IOS,但其他人可以。我搜索了stackoverflow,但我找不到。因为我不想使用其他软件,所以我想直接通过代码直接传输youtube视频的声音。它也应该在背景上工作。
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:
Flashgot(适用于Firefox)有一种方法只能下载Youtube视频的音频。它公开了音频的链接,如下所示:
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.
很有意思。这使得Flashgot只能下载音频并跳过视频,从而节省了带宽。我缺少详细信息,比如Flashgot如何创建此链接,但如果Flashgot有办法,那么其他HTTP客户端也可以这样做。
3
According to the Youtube API blog post, the only options you have of playing youtube on iOS is to link to the video (and have the internal YouTube app play the video), or link from a UIWebView and play from there. Audio-only playback is not supported.
根据Youtube API博客文章,您在iOS上播放youtube的唯一选项是链接到视频(并让内部YouTube应用播放视频),或者从UIWebView链接并从那里播放。不支持纯音频播放。
2
You can't. The data stream that you receive from youtube includes both video/audio streams.
你不能。您从youtube收到的数据流包括视频/音频流。
What you do with the data, it's up to you. This thread has interesting info on the subject.
您对数据做了什么,这取决于您。这个主题有关于这个主题的有趣信息。
1
I would use a MPMoviePlayerController and hide it's view.
我会使用MPMoviePlayerController并隐藏它的视图。
1
Using Audacity software, you could record the audio played on your computer from any source. Since Audacity is open source and you can find open source browsers, you could combine them and get the audio from youtube. Of course its a lot of work, but I am only saying it could be possible unlike others.
使用Audacity软件,您可以从任何来源录制计算机上播放的音频。由于Audacity是开源的,你可以找到开源浏览器,你可以将它们组合起来并从youtube获取音频。当然它有很多工作,但我只是说它可能与其他工作不同。
1
mps-youtube a CLI solution. More details here.
mps-youtube一个CLI解决方案。更多细节在这里。
VLC can do that too if started without video - more here.
如果在没有视频的情况下启动,VLC也可以这样做 - 更多信息。
mplayer can be used with the command mplayer -novideo URL
mplayer可以与命令mplayer -novideo URL一起使用
mpv can be used with the command mpv --no-video URL
mpv可以与命令mpv --no-video URL一起使用
Youtube Viewer, a CLI video player can be also used as indicated here.
还可以使用Youtube Viewer,一个CLI视频播放器,如下所示。
As indicated in another answer the Flashgot addon for Firefox can identify in order to download an audio of a Youtube video. It will display a list of available streams for each video.
如另一个答案中所示,Firefox的Flashgot插件可以识别以下载Youtube视频的音频。它将显示每个视频的可用流列表。
The idea is to start the youtube stream in an external player, but to be able to select only the audio stream with the Flashgot addon in Firefox by adding the external player as Flashgot "downloader" (like here) and then, after starting the youtube video in Firefox, using Flashgot to play only the audio stream by going to 'Available formats/DASH (separate audio and video tracks)'
我的想法是在外部播放器中启动youtube流,但是通过将外部播放器添加为Flashgot“downloader”(如此处),然后在启动youtube之后,能够通过Firefox中的Flashgot插件选择音频流Firefox中的视频,使用Flashgot通过转到'可用格式/ DASH(单独的音频和视频轨道)来播放音频流
[
and select the specific audio track.
并选择特定的音轨。
[
Multimedia players can be assigned in Flashgot instead of a downloader, like VLC or SMPlayer, as most video players seem able to do the job (in Linux; for Windows, see below update); or even audio players like Clementine, although some audio players may not work.
多媒体播放器可以在Flashgot中分配,而不是像VLC或SMPlayer这样的下载器,因为大多数视频播放器似乎能够完成这项工作(在Linux中;对于Windows,请参见下面的更新);甚至像Clementine这样的音频播放器,虽然有些音频播放器可能无法正常工作。
It will start after a few seconds, some players after more than others. The fastest in Linux seems to be SMPlayer .
它将在几秒钟后开始,一些玩家比其他玩家更多。 Linux中最快的似乎是SMPlayer。
UPDATE:
Flashgot has to be up to date.
Flashgot必须是最新的。
In Windows, Flashgot seems to display some audio streams in a different location than in the above image, that is already on the first list (before the DASH list). SMPlayer works the best AFAICT. VLC works, but not with all the audio streams listed by Flashgot. Clementine, Foobar2000 and XMPlay failed. It may be an overall-Windows codecs problem. MPC-HC starts but doesn't buffer correctly and stops long before it should.
在Windows中,Flashgot似乎在与上图不同的位置显示一些音频流,这已经在第一个列表中(在DASH列表之前)。 SMPlayer是最好的AFAICT。 VLC可以工作,但不适用于Flashgot列出的所有音频流。 Clementine,Foobar2000和XMPlay失败了。它可能是整体Windows编解码器问题。 MPC-HC启动但没有正确缓冲并在应该停止之前很久就停止了。
1
There are separate streams for audio and video. This is by default in mp4 to flash conversion.
音频和视频有单独的流。默认情况下,这是mp4到闪存转换。
You can get the combined stream in flash format or separate in mp4 form.
您可以获得Flash格式的组合流或以mp4格式分离。
Exemple: [Headphones Stereo Test (HD)][youtube.com/watch?v=ZjAQylVPU3I]
例如:[耳机立体声测试(HD)] [youtube.com/watch?v=ZjAQylVPU3I]
contain
[the flash stream][youtube.com/v/ZjAQylVPU3I]
[flash stream] [youtube.com/v/ZjAQylVPU3I]
containing the combination of audio stream and video stream in mp4 format.
包含mp4格式的音频流和视频流的组合。
*I'm sorry but the links will not work because they are customized based on ip , expire data , and other things.
*对不起,但链接不起作用,因为它们是基于ip,过期数据和其他东西定制的。
To get these links i used uBlock origin for chrome because it has the logger function showing all connections made to server. search for : mime=video and you can see all links then remove the range to get full length. Same with mime=audio and also you can use that for stream in other flash players but it is against the Terms of Service.
为了获得这些链接,我使用uBlock origin作为chrome,因为它具有记录器功能,显示了对服务器的所有连接。搜索:mime = video,你可以看到所有链接,然后删除范围以获得全长。与mime = audio相同,您也可以将其用于其他Flash播放器中的流,但这违反了服务条款。