热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何仅从YouTube流式传输视频的声音?-HowcanIstreamonlythesoundofavideofromYouTube?

Iwouldliketostreamonlysoundfromyoutube.IneedthisforIOSbutotherscanbeok.Ihavesea

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 个解决方案

#1


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客户端也可以这样做。

#2


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链接并从那里播放。不支持纯音频播放。

#3


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.

您对数据做了什么,这取决于您。这个主题有关于这个主题的有趣信息。

#4


1  

I would use a MPMoviePlayerController and hide it's view.

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

#5


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获取音频。当然它有很多工作,但我只是说它可能与其他工作不同。

#6


1  

In Linux:

  • 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视频播放器,如下所示。

A cross-platform solution:

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(单独的音频和视频轨道)来播放音频流

[enter image description here

and select the specific audio track.

并选择特定的音轨。

[enter image description here

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启动但没有正确缓冲并在应该停止之前很久就停止了。

#7


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播放器中的流,但这违反了服务条款。


推荐阅读
  • 在Android开发中,使用Picasso库可以实现对网络图片的等比例缩放。本文介绍了使用Picasso库进行图片缩放的方法,并提供了具体的代码实现。通过获取图片的宽高,计算目标宽度和高度,并创建新图实现等比例缩放。 ... [详细]
  • 本文主要解析了Open judge C16H问题中涉及到的Magical Balls的快速幂和逆元算法,并给出了问题的解析和解决方法。详细介绍了问题的背景和规则,并给出了相应的算法解析和实现步骤。通过本文的解析,读者可以更好地理解和解决Open judge C16H问题中的Magical Balls部分。 ... [详细]
  • 本文介绍了在Cpp中将字符串形式的数值转换为int或float等数值类型的方法,主要使用了strtol、strtod和strtoul函数。这些函数可以将以null结尾的字符串转换为long int、double或unsigned long类型的数值,且支持任意进制的字符串转换。相比之下,atoi函数只能转换十进制数值且没有错误返回。 ... [详细]
  • 抽空写了一个ICON图标的转换程序
    抽空写了一个ICON图标的转换程序,支持png\jpe\bmp格式到ico的转换。具体的程序就在下面,如果看的人多,过两天再把思路写一下。 ... [详细]
  • 我正在为我的Symfony2项目构建一个搜索功能,我为它编写了SQL,如下所示:SELECTdlc.title,dlc.description,dlc.keywordsFROMSh ... [详细]
  • 本文介绍了如何使用PHP向系统日历中添加事件的方法,通过使用PHP技术可以实现自动添加事件的功能,从而实现全局通知系统和迅速记录工具的自动化。同时还提到了系统exchange自带的日历具有同步感的特点,以及使用web技术实现自动添加事件的优势。 ... [详细]
  • 云原生边缘计算之KubeEdge简介及功能特点
    本文介绍了云原生边缘计算中的KubeEdge系统,该系统是一个开源系统,用于将容器化应用程序编排功能扩展到Edge的主机。它基于Kubernetes构建,并为网络应用程序提供基础架构支持。同时,KubeEdge具有离线模式、基于Kubernetes的节点、群集、应用程序和设备管理、资源优化等特点。此外,KubeEdge还支持跨平台工作,在私有、公共和混合云中都可以运行。同时,KubeEdge还提供数据管理和数据分析管道引擎的支持。最后,本文还介绍了KubeEdge系统生成证书的方法。 ... [详细]
  • IhaveconfiguredanactionforaremotenotificationwhenitarrivestomyiOsapp.Iwanttwodiff ... [详细]
  • 生成对抗式网络GAN及其衍生CGAN、DCGAN、WGAN、LSGAN、BEGAN介绍
    一、GAN原理介绍学习GAN的第一篇论文当然由是IanGoodfellow于2014年发表的GenerativeAdversarialNetworks(论文下载链接arxiv:[h ... [详细]
  • 本文介绍了计算机网络的定义和通信流程,包括客户端编译文件、二进制转换、三层路由设备等。同时,还介绍了计算机网络中常用的关键词,如MAC地址和IP地址。 ... [详细]
  • CF:3D City Model(小思维)问题解析和代码实现
    本文通过解析CF:3D City Model问题,介绍了问题的背景和要求,并给出了相应的代码实现。该问题涉及到在一个矩形的网格上建造城市的情景,每个网格单元可以作为建筑的基础,建筑由多个立方体叠加而成。文章详细讲解了问题的解决思路,并给出了相应的代码实现供读者参考。 ... [详细]
  • 本文介绍了在CentOS上安装Python2.7.2的详细步骤,包括下载、解压、编译和安装等操作。同时提供了一些注意事项,以及测试安装是否成功的方法。 ... [详细]
  • 本文由编程笔记#小编整理,主要介绍了关于数论相关的知识,包括数论的算法和百度百科的链接。文章还介绍了欧几里得算法、辗转相除法、gcd、lcm和扩展欧几里得算法的使用方法。此外,文章还提到了数论在求解不定方程、模线性方程和乘法逆元方面的应用。摘要长度:184字。 ... [详细]
  • 网卡工作原理及网络知识分享
    本文介绍了网卡的工作原理,包括CSMA/CD、ARP欺骗等网络知识。网卡是负责整台计算机的网络通信,没有它,计算机将成为信息孤岛。文章通过一个对话的形式,生动形象地讲述了网卡的工作原理,并介绍了集线器Hub时代的网络构成。对于想学习网络知识的读者来说,本文是一篇不错的参考资料。 ... [详细]
  • Question该提问来源于开源项目:react-native-device-info/react-native-device-info ... [详细]
author-avatar
阡蓝fliona
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有