问题
I have created RTSP Server. Client is VLC Media Player. It connects with my server in the following way:
OPTIONS rtsp://192.168.1.6:5554/camera RTSP/1.0
CSeq: 2
User-Agent: LibVLC/2.2.4 (LIVE555 Streaming Media v2016.02.22)
RTSP/1.0 200 OK
Session: 698955009;timeout=60
Expires: 0
Server: RTSP Camera Server (Android) ver. 1.8
Public: DESCRIBE,SETUP,TEARDOWN,PLAY,PAUSE,GET_PARAMETER,SET_PARAMETER
Cache-Control: no-cache
DESCRIBE rtsp://192.168.1.6:5554/camera RTSP/1.0
CSeq: 3
User-Agent: LibVLC/2.2.4 (LIVE555 Streaming Media v2016.02.22)
Accept: application/sdp
RTSP/1.0 200 OK
Content-Base: rtsp://192.168.1.6:5554/camera
Content-Length: 269
Session: 698955009;timeout=60
Expires: 0
Content-Type: application/sdp
Server: RTSP Camera Server (Android) ver. 1.8
Cache-Control: no-cache
v=0
o=- 0 0 IN IP4 192.168.1.6
s=RTSP_CAMERA
i=N/A
c=IN IP4 192.168.1.6
t=0 0
a=recvonly
m=video 0 RTP/AVP 96
a=rtpmap:96 H264/90000
a=control:trackID=0
a=fmtp:96 packetization-mode=1;profile-level-id=640029;sprop-parameter-sets=Z2QAKawbGsBQBbk=,aOpDyw==;
SETUP rtsp://192.168.1.6:5554/camera/trackID=0 RTSP/1.0
CSeq: 4
User-Agent: LibVLC/2.2.4 (LIVE555 Streaming Media v2016.02.22)
Transport: RTP/AVP/TCP;unicast;interleaved=0-1
RTSP/1.0 200 OK
Transport: RTP/AVP/UDP;unicast;ssrc=7e15a85d;interleaved=0-1;mode=play
Session: 698955009;timeout=60
Server: RTSP Camera Server (Android) ver. 1.8
Cache-Control: no-cache
Expires: 0
PLAY rtsp://192.168.1.6:5554/camera RTSP/1.0
CSeq: 5
User-Agent: LibVLC/2.2.4 (LIVE555 Streaming Media v2016.02.22)
Session: 698955009
Range: npt=0.000-
RTSP/1.0 200 OK
Session: 698955009;timeout=60
Server: RTSP Camera Server (Android) ver. 1.8
Cache-Control: no-cache
Expires: 0
... sending video.mp4 ...
But VLC don't playing video. I tried to send video files in different formats (for example, 3GP, MOV), it doesn't works too. Do I must encode the video? Or maybe any of server responses are incorrect? So, my question is how to stream media file through RTSP and is it possible enough.
回答1:
You don't send "an mp4 file" over RTSP, an mp4 files is just a container for the media samples. Instead you want to packetise the media data stored inside the mp4 file in RTP packets. In the SDP example in your question, you are wanting to send H.264 media which means that you have to packetise the NAL units according to RFC6184.
Also, you are using interleaved mode which means that you must multiplex the RTP and RTCP packets over the TCP connection used for the RTSP interchange. RFC2326 has a section explaining how to do this.
In summary, it sounds like you are trying to stream the mp4 files directly. Instead you need to parse the mp4 files and extract NAL units which then need to be packetised over RTP and multiplexed over the RTSP TCP connection. Alternatively, decide not to interleave and send the packets over UDP. Be sure to implement the correct packetisation mode of RFC6184.
来源:https://stackoverflow.com/questions/42654864/is-it-possible-to-stream-mp4-video-file-through-rtsp-protocol