2013-04-05 158 views
7

對於我的應用程序,我必須從甲板連接卡流到Android應用程序(我必須是一個實時流,所以HLS或RTSP似乎是很好的解決方案,因爲我的應用程序的目標是Android 3+ )。我使用decklink sdk重新編譯了VLC,並且能夠通過網絡直播到另一臺電腦(但它僅與RTSP一起工作60秒)。VLC RTSP直播到Android

這裏是我的嘗試:

  • HTTP流:

    ./vlc -vvv decklink:// --sout 
    '#transcode{vcodec=mp4v,acodec=mpga,vb=56,ab=24,channels=1} 
    :standard{access=http{use-key-frames},mux=ts,dst=:3001/stream.mpeg}' 
    

它是工作在Android的VLC 0.0.11,但只有在無線網絡,而不是3G。而且我無法使用VideoView在我的應用中播放它。這裏是我使用的代碼和對應的錯誤消息:

String url = "http://134.246.63.169:5554/stream.mpeg"; 

VideoView videoView = (VideoView) this.findViewById(R.id.videoView); 
videoView.setVideoURI(Uri.parse(url));   
videoView.setMediaController(new MediaController(this)); 
videoView.requestFocus(); 
videoView.start(); 

錯誤消息:

04-08 15:26:46.272: D/MediaPlayer(16349): Couldn't open file on client side, trying server side 
04-08 15:26:46.272: V/ChromiumHTTPDataSource(7680): connect on behalf of uid 1080867789 
04-08 15:26:46.272: I/ChromiumHTTPDataSource(7680): connect to http://134.246.63.169:8554/ @0 
04-08 15:26:46.302: I/AwesomePlayer(7680): AwesomePlayer::AwesomePlayer()in 
04-08 15:26:46.302: I/AwesomePlayer(7680): AwesomePlayer::AwesomePlayer()aftermClient.connect() 
04-08 15:26:46.302: I/AwesomePlayer(7680): setDataSource_l('http://134.246.63.169:5554/') 
04-08 15:26:46.302: W/MediaPlayer(16349): info/warning (701, 0) 
04-08 15:26:46.302: V/ChromiumHTTPDataSource(7680): connect on behalf of uid 10067 
04-08 15:26:46.302: I/ChromiumHTTPDataSource(7680): connect to http://134.246.63.169:5554/ @0 
04-08 15:26:46.342: I/ActivityManager(272): Displayed fr.ifremer.testrtsp/.MainActivity: +183ms 
04-08 15:26:46.382: I/MediaPlayer(16349): Info (701,0) 
04-08 15:27:07.592: E/MediaPlayer(16349): error (1, -2147483648) 
04-08 15:27:07.592: E/MediaPlayer(16349): Error (1,-2147483648) 
  • RTSP:

我用this page由谷歌建議的編碼選項,例如:

  • 視頻編解碼器:H264
  • 音頻編解碼器:AAC
  • 視頻比特率:56
  • 音頻比特率:24個
  • 音頻通道:1
  • 尺寸:176×144

    ./vlc -vvv decklink:// --sout-ffmpeg-strict=-2 --sout 
    '#transcode{width=176,height=144,vcodec=h264,acodec=mp4a,vb=56,ab=24,channels=1} 
    :rtp{dst=134.246.63.169,port-video=5554,port-audio=5556,sdp=rtsp://134.246.63.169:5554/stream.sdp}' 
    

我能夠在VLC桌面播放流,但不能在Android中播放(即使在Android VLC版本或默認的Goo中gle視頻播放器:/)。 如果我沒有指定muxer,我也可以用它來播放QuickTime(如果我指定muxer,無論是ts還是ps,我都沒有視頻,如果我嘗試另一個muxer,VLC告訴我,我只允許使用TS或RTP PS)

如果我嘗試用谷歌視頻播放器,我得到的LOCAT這些消息:

04-08 15:32:45.792: D/MediaPlayer(13688): Couldn't open file on client side, trying server side 
04-08 15:32:45.802: W/MediaPlayer(13688): info/warning (701, 0) 
04-08 15:32:45.812: I/MediaPlayer(13688): Info (701,0) 
04-08 15:32:45.812: D/MediaPlayer(13688): getMetadata 
04-08 15:32:45.812: E/MediaPlayerService(7680): getMetadata failed -38 
04-08 15:32:45.852: I/MyHandler(7680): connection request completed with result 0 (Success) 
04-08 15:32:45.882: I/ARTSPConnection(7680): status: RTSP/1.0 200 OK 
04-08 15:32:45.882: I/MyHandler(7680): DESCRIBE completed with result 0 (Success) 
04-08 15:32:45.882: I/ASessionDescription(7680): v=0 
04-08 15:32:45.882: I/ASessionDescription(7680): o=- 15352003113363922923 15352003113363922923 IN IP4 to63-169.ifremer.fr 
04-08 15:32:45.882: I/ASessionDescription(7680): s=Unnamed 
04-08 15:32:45.882: I/ASessionDescription(7680): i=N/A 
04-08 15:32:45.882: I/ASessionDescription(7680): c=IN IP4 134.246.63.169 
04-08 15:32:45.882: I/ASessionDescription(7680): t=0 0 
04-08 15:32:45.882: I/ASessionDescription(7680): a=tool:vlc 2.0.5 
04-08 15:32:45.882: I/ASessionDescription(7680): a=recvonly 
04-08 15:32:45.882: I/ASessionDescription(7680): a=type:broadcast 
04-08 15:32:45.882: I/ASessionDescription(7680): a=charset:UTF-8 
04-08 15:32:45.882: I/ASessionDescription(7680): a=control:rtsp://134.246.63.169:5554/stream.sdp 
04-08 15:32:45.882: I/ASessionDescription(7680): m=audio 5556 RTP/AVP 96 
04-08 15:32:45.882: I/ASessionDescription(7680): b=AS:24 
04-08 15:32:45.882: I/ASessionDescription(7680): b=RR:0 
04-08 15:32:45.882: I/ASessionDescription(7680): a=rtpmap:96 mpeg4-generic/48000 
04-08 15:32:45.882: I/ASessionDescription(7680): a=fmtp:96 streamtype=5; profile-level-id=15; mode=AAC-hbr; config=118856e500; SizeLength=13; IndexLength=3; IndexDeltaLength=3; Profile=1; 
04-08 15:32:45.882: I/ASessionDescription(7680): a=control:rtsp://134.246.63.169:5554/stream.sdp/trackID=0 
04-08 15:32:45.882: I/ASessionDescription(7680): m=video 5554 RTP/AVP 96 
04-08 15:32:45.882: I/ASessionDescription(7680): b=AS:56 
04-08 15:32:45.882: I/ASessionDescription(7680): b=RR:0 
04-08 15:32:45.882: I/ASessionDescription(7680): a=rtpmap:96 H264/90000 
04-08 15:32:45.882: I/ASessionDescription(7680): a=fmtp:96 packetization-mode=1;profile-level-id=64000b;sprop-parameter-sets=Z2QAC6zZQsTv/AC0ALBAAAADAEAAAAyjxQplgA==,aOvssiw=; 
04-08 15:32:45.882: I/ASessionDescription(7680): a=control:rtsp://134.246.63.169:5554/stream.sdp/trackID=1 
04-08 15:32:45.982: I/ARTSPConnection(7680): status: RTSP/1.0 200 OK 
04-08 15:32:45.982: I/MyHandler(7680): SETUP(1) completed with result 0 (Success) 
04-08 15:32:45.982: I/MyHandler(7680): server specified timeout of 60 secs. 
04-08 15:32:45.992: W/MyHandler(7680): Missing 'source' field in Transport response. Using RTSP endpoint address. 
04-08 15:32:45.992: I/APacketSource(7680): dimensions 176x144 
04-08 15:32:46.012: I/ARTSPConnection(7680): status: RTSP/1.0 200 OK 
04-08 15:32:46.022: I/MyHandler(7680): SETUP(2) completed with result 0 (Success) 
04-08 15:32:46.022: I/MyHandler(7680): server specified timeout of 60 secs. 
04-08 15:32:46.022: W/MyHandler(7680): Missing 'source' field in Transport response. Using RTSP endpoint address. 
04-08 15:32:46.022: W/MyHandler(7680): Server picked an odd RTP port, it should've picked an even one, we'll let it pass for now, but this may break in the future. 
04-08 15:32:46.082: I/ARTSPConnection(7680): status: RTSP/1.0 200 OK 
04-08 15:32:46.082: D/dalvikvm(13688): GC_FOR_ALLOC freed 303K, 7% free 9289K/9927K, paused 35ms, total 36ms 
04-08 15:32:46.092: I/MyHandler(7680): PLAY completed with result 0 (Success) 
04-08 15:32:46.092: I/MyHandler(7680): This is a live stream 
04-08 15:32:48.262: D/AudioHardware(7680): AudioHardware pcm playback is going to standby. 
04-08 15:32:48.262: D/AudioHardware(7680): closePcmOut_l() mPcmOpenCnt: 1 
04-08 15:32:56.092: W/MyHandler(7680): Never received any data, switching transports. 
04-08 15:32:56.112: I/ARTSPConnection(7680): status: RTSP/1.0 200 OK 
04-08 15:32:56.122: I/MyHandler(7680): TEARDOWN completed with result 0 (Success) 
04-08 15:32:56.122: I/MyHandler(7680): connection request completed with result 0 (Success) 
04-08 15:32:56.152: I/ARTSPConnection(7680): status: RTSP/1.0 200 OK 
04-08 15:32:56.152: I/MyHandler(7680): DESCRIBE completed with result 0 (Success) 
04-08 15:32:56.152: I/ASessionDescription(7680): v=0 
04-08 15:32:56.152: I/ASessionDescription(7680): o=- 15352003157473632156 15352003157473632156 IN IP4 to63-169.ifremer.fr 
04-08 15:32:56.152: I/ASessionDescription(7680): s=Unnamed 
04-08 15:32:56.152: I/ASessionDescription(7680): i=N/A 
04-08 15:32:56.152: I/ASessionDescription(7680): c=IN IP4 134.246.63.169 
04-08 15:32:56.152: I/ASessionDescription(7680): t=0 0 
04-08 15:32:56.152: I/ASessionDescription(7680): a=tool:vlc 2.0.5 
04-08 15:32:56.152: I/ASessionDescription(7680): a=recvonly 
04-08 15:32:56.152: I/ASessionDescription(7680): a=type:broadcast 
04-08 15:32:56.152: I/ASessionDescription(7680): a=charset:UTF-8 
04-08 15:32:56.152: I/ASessionDescription(7680): a=control:rtsp://134.246.63.169:5554/stream.sdp 
04-08 15:32:56.152: I/ASessionDescription(7680): m=audio 5556 RTP/AVP 96 
04-08 15:32:56.152: I/ASessionDescription(7680): b=AS:24 
04-08 15:32:56.152: I/ASessionDescription(7680): b=RR:0 
04-08 15:32:56.152: I/ASessionDescription(7680): a=rtpmap:96 mpeg4-generic/48000 
04-08 15:32:56.152: I/ASessionDescription(7680): a=fmtp:96 streamtype=5; profile-level-id=15; mode=AAC-hbr; config=118856e500; SizeLength=13; IndexLength=3; IndexDeltaLength=3; Profile=1; 
04-08 15:32:56.152: I/ASessionDescription(7680): a=control:rtsp://134.246.63.169:5554/stream.sdp/trackID=0 
04-08 15:32:56.152: I/ASessionDescription(7680): m=video 5554 RTP/AVP 96 
04-08 15:32:56.152: I/ASessionDescription(7680): b=AS:56 
04-08 15:32:56.152: I/ASessionDescription(7680): b=RR:0 
04-08 15:32:56.152: I/ASessionDescription(7680): a=rtpmap:96 H264/90000 
04-08 15:32:56.152: I/ASessionDescription(7680): a=fmtp:96 packetization-mode=1;profile-level-id=64000b;sprop-parameter-sets=Z2QAC6zZQsTv/AC0ALBAAAADAEAAAAyjxQplgA==,aOvssiw=; 
04-08 15:32:56.152: I/ASessionDescription(7680): a=control:rtsp://134.246.63.169:5554/stream.sdp/trackID=1 
04-08 15:32:56.222: I/ARTSPConnection(7680): status: RTSP/1.0 461 Unsupported transport 
04-08 15:32:56.222: I/MyHandler(7680): SETUP(1) completed with result 0 (Success) 
04-08 15:32:56.222: I/APacketSource(7680): dimensions 176x144 
04-08 15:32:56.242: I/ARTSPConnection(7680): status: RTSP/1.0 461 Unsupported transport 
04-08 15:32:56.252: I/MyHandler(7680): SETUP(2) completed with result 0 (Success) 
04-08 15:32:56.272: E/MediaPlayer(13688): error (1, -2147483648) 
04-08 15:32:56.272: E/MediaPlayer(13688): Error (1,-2147483648) 
04-08 15:32:56.272: D/VideoView(13688): Error: 1,-2147483648 

我想這個問題被指出與「狀態:RTSP/1.0 461不支持運輸「,但我看不到我可以改變什麼:我已經打開了我使用的端口,而且我確實收到了另一臺計算機上的視頻。

在Android手機上,我可以播放一些我在網上找到的rtsp流,例如:rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov。 所以它應該是可能的。

如果有人能幫助...!

+0

問題是否解決? – 2013-05-27 12:55:58

+0

我也想開發一個顯示IP攝像機直播的應用程序。我已經驗證了android的videoview不支持的RSTP url。我也想記錄RSTP ...你能指導我如何實現這樣的功能嗎? – 2013-05-27 12:57:12

回答

6

最後,這是一個網絡問題,我通過MacBook WiFi共享連接我的設備,似乎它阻塞了RTSP流。現在我正在使用路由器,它在RTSP中工作(我仍然無法在Android VideoView中接收HTTP流)。 不過,我仍然有一個超時問題:RTSP流在60秒後停止,因爲VideoView不發送保持活動的消息。我會嘗試自己做...

+0

所以錯誤味精:狀態:RTSP/1.0 461不支持的傳輸真的意味着它的網絡問題? – Robert 2013-12-17 07:56:23

0

我用openRTSP命令測試了我的rtsp服務器。

這是UDP端口被阻塞。

如果訪問RTSP沒有-t:

-> $ openRTSP <rtsp_url> 

我日誌告訴我:

// omit lots of lines.. 
Created receiver for "video/H264" subsession (client ports 63346-63347) 
Sending request: SETUP rtsp://61.218.52.250:554/live/ch00_0/trackID=0 RTSP/1.0 
CSeq: 4 
User-Agent: openRTSP (LIVE555 Streaming Media v2013.12.16) 
Transport: RTP/AVP;unicast;client_port=63346-63347 

Received 47 new bytes of response data. 
Received a complete SETUP response: 
RTSP/1.0 461 Unsupported Transport 
CSeq: 4 

Failed to setup "video/H264" subsession: 461 Unsupported Transport 

因此改變與對TCP:

-> $ openRTSP -t <rtsp_url> 

它啓動成功接收數據。

// omit lots of lines.. 
Opened URL "rtsp://61.218.52.250:554/live/ch00_0", returning a SDP description: 
v=0 
o=- 1 1 IN IP4 127.0.0.1 
s=Ubiquiti Live 
i=UBNT Streaming Media 
c=IN IP4 0.0.0.0 
t=0 0 
m=video 0 RTP/AVP 99 
b=AS:50000 
a=framerate:25 
a=x-dimensions:1280,720 
a=x-vendor-id:ubnt,a521 
a=x-rtp-ts:4617405454576779984 
a=rtpmap:99 H264/90000 
a=fmtp:99 profile-level-id=42A01E;packetization-mode=1;sprop-parameter-sets=Z0IAKOkAoAt1xIAG3dAAzf5gDYgQlA==,aM4xUg== 
a=control:trackID=0 

Sending request: SETUP rtsp://61.218.52.250:554/live/ch00_0/trackID=0 RTSP/1.0 
CSeq: 4 
User-Agent: openRTSP (LIVE555 Streaming Media v2013.12.16) 
Transport: RTP/AVP/TCP;unicast;interleaved=0-1 


Received 107 new bytes of response data. 
Received a complete SETUP response: 
RTSP/1.0 200 OK 
CSeq: 4 
Transport: RTP/AVP/TCP;unicast;interleaved=0-1 
Session: E090B5503236A1BFB7CE 


Setup "video/H264" subsession (client ports 54884-54885) 
Sending request: PLAY rtsp://61.218.52.250:554/live/ch00_0/ RTSP/1.0 
CSeq: 5 
User-Agent: openRTSP (LIVE555 Streaming Media v2013.12.16) 
Session: E090B5503236A1BFB7CE 
Range: npt=0.000- 


Received 159 new bytes of response data. 
Received a complete PLAY response: 
RTSP/1.0 200 OK 
CSeq: 5 
Session: E090B5503236A1BFB7CE 
Range: npt=now- 
RTP-Info: url=rtsp://61.218.52.250:554/live/ch00_0//trackID=0;seq=41402;rtptime=0 


Started playing session 
Data is being streamed (signal with "kill -HUP 96432" or "kill -USR1 96432" to terminate)... 
Received 47 new bytes of response data. 
Received 1424 new bytes of response data. 
Received 1424 new bytes of response data. 
Received 1424 new bytes of response data. 
Received 1424 new bytes of response data. 
Received 1448 new bytes of response data. 
Received 1448 new bytes of response data. 

Ref to openRTSP basics.

現在我得如何自動切換找出該TCP的Android系統。

0

請嘗試VLC:

VLC some_file.mp4 -I HTTP --sout「#transcode {soverlay,AB = 128,採樣率= 44100,通道= 2,acodec = MP4A,​​了vcodec = H264,寬度= 480,高度= 270,VFILTER = 「畫布{寬度= 480,高度= 270,縱橫= 16:9}」,FPS = 25,VB = 800,VENC = X264 {水平= 12,無CABAC,次亞= 20,threads = 4,bframes = 0,min-keyint = 1,keyint = 50}}:gather:rtp {mp4a-latm,sdp = rtsp://0.0.0.0:5554/stream.sdp}「

和Android代碼:

@Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

     final VideoView vidView = (VideoView)findViewById(R.id.myVideo); 

     MediaController vidControl = new MediaController(this); 
     vidControl.setAnchorView(vidView); 
     vidView.setMediaController(vidControl); 

     vidView.setVideoPath("rtsp://137.110.92.231:5554/stream.sdp"); 

     vidView.start(); 
     }