How to get a video stream from an RTMP server to Android?

馋奶兔 提交于 2019-12-25 04:38:24

问题


I want to implement streaming from an RTMP server. For example, below is the link of an RTMP server.

http://usher.justin.tv/find/CHANNELNAME.json?type=any

And want to do streaming of it.

I found one way: It is connected to a SWF file on a Twitch server (it is too slow) ... How do I convert it to VideoView from rtmp:// to avoid using the Twitch API?

Answer after request:

[
{"node": "video10-2.arn01", "needed_info": "","play": "jtv_FO2coLXGNLzCXtvR","meta_game": "Diablo III: Reaper of Souls", "video_height": 720, "bitrate": 2915.1875, "broadcast_part": 5, "rank": 0, "persistent": "true", "cluster": "arn01", "token": "76b3d8aae0e6eee2bcda8d1acc34103f1a73b595:{\"swfDomains\": [\"justin.tv\", \"jtvx.com\", \"xarth.com\", \"twitchtv.com\", \"twitch.tv\", \"newjtv.com\", \"jtvnw.net\", \"wdtinc.com\", \"imapweather.com\", \"facebook.com\", \"starcrafting.com\"], \"streamName\": \"jtv_FO2coLXGNLzCXtvR\", \"expiration\": 1385121067, \"server\": \"video10-2.arn01\"}", "connect": "rtmp://192.16.65.94/app", "broadcast_id": 7587457488, "type": "live", "display": "Source", "find_type": "dist"},
{"node": "video12-1.fra01", "needed_info": "", "play": "jtv_LuAij7o0_zozQ4jY", "meta_game": "Diablo III: Reaper of Souls", "video_height": 720, "bitrate": 1600, "broadcast_part": 1, "rank": 1, "persistent": "true", "cluster": "fra01", "token": "b4db7f59d3b4d723624ee50ed2d69519d1a4cebb:{\"swfDomains\": [\"justin.tv\", \"jtvx.com\", \"xarth.com\", \"twitchtv.com\", \"twitch.tv\", \"newjtv.com\", \"jtvnw.net\", \"wdtinc.com\", \"imapweather.com\", \"facebook.com\", \"starcrafting.com\"], \"streamName\": \"jtv_LuAij7o0_zozQ4jY\", \"expiration\": 1385121067, \"server\": \"video12-1.fra01\"}", "connect": "rtmp://199.9.254.232/app", "broadcast_id": 7587458496, "type": "high", "display": "High", "find_type": "dist"},
{"node": "video15-2.arn01", "needed_info": "", "play": "jtv_e38UUDs1WLMP9wlc", "meta_game": "Diablo III: Reaper of Souls", "video_height": 360, "bitrate": 350, "broadcast_part": 1, "rank": 3, "persistent": "true", "cluster": "arn01", "token": "c416673c070354e1a33edcdb535a195463cd9702:{\"swfDomains\": [\"justin.tv\", \"jtvx.com\", \"xarth.com\", \"twitchtv.com\", \"twitch.tv\", \"newjtv.com\", \"jtvnw.net\", \"wdtinc.com\", \"imapweather.com\", \"facebook.com\", \"starcrafting.com\"], \"streamName\": \"jtv_e38UUDs1WLMP9wlc\", \"expiration\": 1385121067, \"server\": \"video15-2.arn01\"}", "connect": "rtmp://192.16.65.99/app", "broadcast_id": 7587458512, "type": "low", "display": "Low", "find_type": "dist"},
{"node": "video12-1.fra01", "needed_info": "", "play": "jtv_bRMbL_ROsoHAegM2", "meta_game": "Diablo III: Reaper of Souls", "video_height": 480, "bitrate": 800, "broadcast_part": 1, "rank": 2, "persistent": "true", "cluster": "fra01", "token": "bed50de10852dd0f7a24d687f43a10463557b5a3:{\"swfDomains\": [\"justin.tv\", \"jtvx.com\", \"xarth.com\", \"twitchtv.com\", \"twitch.tv\", \"newjtv.com\", \"jtvnw.net\", \"wdtinc.com\", \"imapweather.com\", \"facebook.com\", \"starcrafting.com\"], \"streamName\": \"jtv_bRMbL_ROsoHAegM2\", \"expiration\": 1385121067, \"server\": \"video12-1.fra01\"}", "connect": "rtmp://199.9.254.232/app", "broadcast_id": 7587458528, "type": "medium", "display": "Medium", "find_type": "dist"}]

I found the best way for getting a stream on a PC: Watch twitch.tv/justin.tv/own3d.tv streams in VLC.

It uses this PHP code: http://bog.no-ip.biz/sc2/stream2vlc.php

But I don't have any idea on how to implement it in an Android project.


回答1:


You can use the Adobe AIR SDK that can run on Android. It is very simple and can work with RTMP by default.




回答2:


As WebView supports RTSP, perhaps you can convert the stream from RTMP to RTSP on the fly.

I didn't try this, but a websearch gave me this for example: RTMP To RTSP re-stream using wowza and xuggler.



来源:https://stackoverflow.com/questions/20141244/how-to-get-a-video-stream-from-an-rtmp-server-to-android

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