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

与世无争的帅哥 提交于 2019-12-12 09:04:10

问题


I am making an app that can stream a live YouTube video to my app. I want to use ExoPlayer. I went through the demo app of ExoPlayer, and the URL they use in DASH streaming is something like this :

"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"

This is working.

I don't know how to get such a URL and I end up here. Does that mean that I can't stream from YouTube even if the video is my own? (especially Live videos) If I can how can I get such a URL for my video?


回答1:


I have learned that DASH URLs are actually something that are internal to Google and you might need to use decoder to be able to get your URL.

For this, you may want to try the following solution given by Karim Abdell Salam in this SO post:

  1. 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.
  2. Now you will get notice to download a file called get_video_info with no extesion.
  3. Try to open this file using notepad and so.
  4. 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
  5. Finally, search for a key called dashmpd and enjoy your URL

You may want to also check these links for more helpful information and updates:

  • YouTube video regarding ExoPlayer: Adaptive video streaming on Android
  • AndroidDev blog - Using ExoPlayer to play Youtube videos, don't know where the example URL's in the demo app are coming from.
  • ExoPlayer Release Notes

Lastly, you may opt to also try playing live videos on android version 4.2.2 without necessarily using an ExoPlayer as mentioned in this SO post.



来源:https://stackoverflow.com/questions/40761192/streaming-a-youtube-live-video-dash-to-android-app-with-exoplayer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!