关于Java:使用ExoPlayer将YouTube实时视频(DASH)流传输到Android应用

Streaming a YouTube live video (DASH) to Android app with ExoPlayer

我正在制作一个可以将实时YouTube视频流式传输到我的应用程序的应用程序。 我想使用ExoPlayer。 我通过了ExoPlayer的演示应用程序,它们在DASH流中使用的URL是这样的:

" uri":" http://www.youtube.com/api/manifest/dash/id/bf5bb2419360daf1/source/youtube?as=fmp4_audio_clear,fmp4_sd_hd_clear&sparams=ip,ipbits,expire,source,id,as&ip= 0.0.0.0&ipbits = 0&expire = 19000000000&signature = 51AF5F39AB0CEC3E5497CD9C900EBFEAECCCB5C7.8506521BFC350652163895D4C26DEE124209AA9E&key = ik0"

可以了

我不知道如何获取这样的URL,我到这里为止。 这是否意味着即使视频是我自己的,我也无法从YouTube流式传输? (尤其是实时视频),如果我能如何为我的视频获得这样的URL?


我了解到DASH URL实际上是Google内部的东西,您可能需要使用解码器才能获取URL。

为此,您可能想尝试Karim Abdell Salam在此SO帖子中提供的以下解决方案:

  • First you need to call this url: http://www.youtube.com/get_video_info?&video_id=v1uyQZNg2vE and don't forget to change the last id with the target one.
  • Now you will get notice to download a file called get_video_info with no extesion.
  • Try to open this file using notepad and so.
  • Now you have the right data but you can't read it because its encoded You need HTML decoder to read this data. Use this one: http://meyerweb.com/eric/tools/dencoder/. Just paste your data and press decode a several times to ensure it decoded well
  • Finally, search for a key called dashmpd and enjoy your URL
  • 您可能还需要检查以下链接,以获取更多有用的信息和更新:

    • 关于ExoPlayer的YouTube视频:Android上的自适应视频流
    • AndroidDev博客-使用ExoPlayer播放Youtube视频,不知道示例应用程序中示例URL的来源。
    • ExoPlayer发行说明

    最后,您也可以选择尝试在Android 4.2.2版上播放实时视频,而不必使用本SO文章中提到的ExoPlayer。