#OpenRTSP的使用
2017-05-19 本文已影响0人
ashura_
保存文件
列举一般使用的的几个命令
-d [time]--------这个是录制时间,就是单位秒,超时后,程序自动结束。
-i -----------以.avi文件格式生成。
-4-------------以.mp4文件格式生成。
-q---------是以.mov文件格式生成。
全部的命令介绍在这里
命令示例:
以mp4格式为例:
openRTSP -4 -d 15 rtsp://192.168.123.244:8554/mtvh.264 >~/Documents/tmp/a.mp4
保存H264裸流
从这里找到的命令
示例:
openRTSP -d 20 -f 3 -w 640 -h 480 -b 400000 rtsp://192.168.123.244:8554/mtvh.264
运行之后,控制台会出现这样
Opening connection to 192.168.123.244, port 8554...
...remote connection opened
Sending request: OPTIONS rtsp://192.168.123.244:8554/mtvh.264 RTSP/1.0
CSeq: 2
User-Agent: openRTSP (LIVE555 Streaming Media v2016.11.28)
Received 152 new bytes of response data.
Received a complete OPTIONS response:
RTSP/1.0 200 OK
CSeq: 2
Date: Tue, Jan 17 2017 02:53:46 GMT
Public: OPTIONS, DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE, GET_PARAMETER, SET_PARAMETER
Sending request: DESCRIBE rtsp://192.168.123.244:8554/mtvh.264 RTSP/1.0
CSeq: 3
User-Agent: openRTSP (LIVE555 Streaming Media v2016.11.28)
Accept: application/sdp
Received 693 new bytes of response data.
Received a complete DESCRIBE response:
RTSP/1.0 200 OK
CSeq: 3
Date: Tue, Jan 17 2017 02:53:46 GMT
Content-Base: rtsp://192.168.123.244:8554/mtvh.264/
Content-Type: application/sdp
Content-Length: 523
v=0
o=- 1484621626312512 1 IN IP4 192.168.123.244
s=H.264 Video, streamed by the LIVE555 Media Server
i=mtvh.264
t=0 0
a=tool:LIVE555 Streaming Media v2016.05.16
a=type:broadcast
a=control:*
a=range:npt=0-
a=x-qt-text-nam:H.264 Video, streamed by the LIVE555 Media Server
a=x-qt-text-inf:mtvh.264
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
b=AS:500
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1;profile-level-id=4D401F;sprop-parameter-sets=Z01AH+iAeAi01AQEBQAAAwABAAADADKPGDES,aOvsTIA=
a=control:track1
Opened URL "rtsp://192.168.123.244:8554/mtvh.264", returning a SDP description:
v=0
o=- 1484621626312512 1 IN IP4 192.168.123.244
s=H.264 Video, streamed by the LIVE555 Media Server
i=mtvh.264
t=0 0
a=tool:LIVE555 Streaming Media v2016.05.16
a=type:broadcast
a=control:*
a=range:npt=0-
a=x-qt-text-nam:H.264 Video, streamed by the LIVE555 Media Server
a=x-qt-text-inf:mtvh.264
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
b=AS:500
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1;profile-level-id=4D401F;sprop-parameter-sets=Z01AH+iAeAi01AQEBQAAAwABAAADADKPGDES,aOvsTIA=
a=control:track1
Created receiver for "video/H264" subsession (client ports 54810-54811)
Sending request: SETUP rtsp://192.168.123.244:8554/mtvh.264/track1 RTSP/1.0
CSeq: 4
User-Agent: openRTSP (LIVE555 Streaming Media v2016.11.28)
Transport: RTP/AVP;unicast;client_port=54810-54811
Received 220 new bytes of response data.
Received a complete SETUP response:
RTSP/1.0 200 OK
CSeq: 4
Date: Tue, Jan 17 2017 02:53:46 GMT
Transport: RTP/AVP;unicast;destination=192.168.123.244;source=192.168.123.244;client_port=54810-54811;server_port=6970-6971
Session: C9C4E30C;timeout=65
Setup "video/H264" subsession (client ports 54810-54811)
Created output file: "video-H264-1"
Sending request: PLAY rtsp://192.168.123.244:8554/mtvh.264/ RTSP/1.0
CSeq: 5
User-Agent: openRTSP (LIVE555 Streaming Media v2016.11.28)
Session: C9C4E30C
Range: npt=0.000-20.000
Received 190 new bytes of response data.
Received a complete PLAY response:
RTSP/1.0 200 OK
CSeq: 5
Date: Tue, Jan 17 2017 02:53:46 GMT
Range: npt=0.000-
Session: C9C4E30C
RTP-Info: url=rtsp://192.168.123.244:8554/mtvh.264/track1;seq=27336;rtptime=246115475
Started playing session
Receiving streamed data (for up to 20.000000 seconds)...
Received RTCP "BYE" on "video/H264" subsession (after 20 seconds)
Sending request: TEARDOWN rtsp://192.168.123.244:8554/mtvh.264/ RTSP/1.0
CSeq: 6
User-Agent: openRTSP (LIVE555 Streaming Media v2016.11.28)
Session: C9C4E30C
Received 65 new bytes of response data.
Received a complete TEARDOWN response:
RTSP/1.0 200 OK
CSeq: 6
Date: Tue, Jan 17 2017 02:54:06 GMT
这行命令会在本目录下生成h264
文件,使用Subline Text
查看即可知道文件流。
左边是
OpenRTSP
保存的,右边是原始流
。
这里说VLC客户端不能播放,OpenRTSP
导出的缺少一些sps
以及pps
信息,导致VLC
无法播放。自己测试,使用本地文件方式确实无法播放,放在live555MediaServer
目录下,作为一个服务是可以播放的,应该在客户端做了兼容。照着修改了playCommon.cpp
表现一样,还需继续研究。
这里指定了输出路径生成的文件是0字节的,不指定默认在当前目录生成一个
video-H264-1
文件是正确的h264
裸流文件。
Demo
用
Mac
程序做了个命令行Demo,可以使用。做成iOS存储路径需要修改
#import <Foundation/Foundation.h>
#import "playCommon.hh"
int main(int argc, const char * argv[]) {
@autoreleasepool {
// insert code here...
NSLog(@"Hello, World!");
//openRTSP(argc,argv);
char *p[] = {"openRTSP","-d","20","rtsp://192.168.123.244:8554/mtvh.264"};
openRTSP(4, p);
}
return 0;
}