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


推荐阅读
  • 本文深入探讨了 Java 中的 Serializable 接口,解释了其实现机制、用途及注意事项,帮助开发者更好地理解和使用序列化功能。 ... [详细]
  • 本文将详细探讨 Java 中提供的不可变集合(如 `Collections.unmodifiableXXX`)和同步集合(如 `Collections.synchronizedXXX`)的实现原理及使用方法,帮助开发者更好地理解和应用这些工具。 ... [详细]
  • 本文将介绍如何编写一些有趣的VBScript脚本,这些脚本可以在朋友之间进行无害的恶作剧。通过简单的代码示例,帮助您了解VBScript的基本语法和功能。 ... [详细]
  • Explore a common issue encountered when implementing an OAuth 1.0a API, specifically the inability to encode null objects and how to resolve it. ... [详细]
  • 深入解析Spring Cloud Ribbon负载均衡机制
    本文详细介绍了Spring Cloud中的Ribbon组件如何实现服务调用的负载均衡。通过分析其工作原理、源码结构及配置方式,帮助读者理解Ribbon在分布式系统中的重要作用。 ... [详细]
  • XNA 3.0 游戏编程:从 XML 文件加载数据
    本文介绍如何在 XNA 3.0 游戏项目中从 XML 文件加载数据。我们将探讨如何将 XML 数据序列化为二进制文件,并通过内容管道加载到游戏中。此外,还会涉及自定义类型读取器和写入器的实现。 ... [详细]
  • 深入解析ESFramework中的AgileTcp组件
    本文详细介绍了ESFramework框架中AgileTcp组件的设计与实现。AgileTcp是ESFramework提供的ITcp接口的高效实现,旨在优化TCP通信的性能和结构清晰度。 ... [详细]
  • 在编译BSP包过程中,遇到了一个与 'gets' 函数相关的编译错误。该问题通常发生在较新的编译环境中,由于 'gets' 函数已被弃用并视为安全漏洞。本文将详细介绍如何通过修改源代码和配置文件来解决这一问题。 ... [详细]
  • Microsoft即将发布WPF/E的CTP(Community Technology Preview)和SDK,标志着RIA(Rich Internet Application)技术的新里程碑。更多详情及下载链接请参见MSDN官方页面。 ... [详细]
  • 本文旨在介绍在iOS平台进行直播技术开发前的准备工作,重点讲解AVFoundation框架的基本概念和使用方法。通过对AVFoundation的深入理解,开发者能够更好地掌握直播应用中的音视频处理技巧。 ... [详细]
  • 在使用 iOS 应用时,遇到网络请求错误是常见的问题。本文将探讨两种常见的错误代码 -1003 和 -1001,并提供详细的解释和解决方案。 ... [详细]
  • 本题探讨如何通过最大流算法解决农场排水系统的设计问题。题目要求计算从水源点到汇合点的最大水流速率,使用经典的EK(Edmonds-Karp)和Dinic算法进行求解。 ... [详细]
  • 本文介绍如何使用 Android 的 Canvas 和 View 组件创建一个简单的绘图板应用程序,支持触摸绘画和保存图片功能。 ... [详细]
  • Nginx 反向代理与负载均衡实验
    本实验旨在通过配置 Nginx 实现反向代理和负载均衡,确保从北京本地代理服务器访问上海的 Web 服务器时,能够依次显示红、黄、绿三种颜色页面以验证负载均衡效果。 ... [详细]
  • 主板IO用W83627THG,用VC如何取得CPU温度,系统温度,CPU风扇转速,VBat的电压. ... [详细]
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社区 版权所有