需求

            VLC2.2.4对接定制的流媒体服务器,流媒体服务器提供RTSP服务


知识准备

    通过命令行打开,进入VLC可执行程序目录:vlc.exe --extraintf=http:logger --verbose=2 --file-logging --logfile=vlc-log.txt

输入URL,可以看到RTSP的交互过程,当前目录下生成日志文件vlc-log.txt


1)VLC连接十秒之后断开

打开调试信息,如下:

core debug: no meta reader modules matched
core debug: `rtsp://192.168.58.173:554/channel=1/trackID=video' successfully opened
live555 error: no data received in 10s, aborting 提示接收数据失败
core debug: EOF reached
core debug: finished input
core debug: removing module "avcodec"
avcodec debug: ffmpeg codec (H264 - MPEG-4 AVC (part 10)) stopped


原因

DESCRIBE指令里面,除了视频的SDP,还提供了音频的SDP,实际上目前流媒体只是支持了视频,通过屏蔽音频解决问题

  x << "v=0\r\n";
  x << "o=- 1109162014219182 0 IN IP4 0.0.0.0\r\n";
  x << "s=Media Server V1.0.1\r\n";
  x << "i=Media Server Session Description : standard\r\n";
  x << "e=NONE\r\n";
  x << "c=IN IP4 0.0.0.0\r\n";
  x << "t=0 0\r\n";
  x << "a=control:*\r\n";
  x << "b=AS:4106\r\n";
  x << "a=range:npt=now-\r\n";
  x << "m=video 0 RTP/AVP 96\r\n";
  x << "i=Video Media\r\n";
  x << "a=rtpmap:96 H264/90000\r\n";
  x << "a=fmtp:96 profile-level-id=4D0014;packetization-mode=0;sprop-parameter-sets=Z2QAH6wsaoFAFum4CAgIEAA=,aO48sAA=\r\n";
  x << "a=control:trackID=video\r\n";
//   x << "b=AS:4096\r\n";
//   x << "m=audio 0 RTP/AVP 8\r\n";
//   x << "i=Audio Media\r\n";
//   x << "a=rtpmap:8 PCMA/8000\r\n";
//   x << "a=control:trackID=audio\r\n";
//   x << "b=AS:10\r\n";
  x << "a=Media_header:MEDIAINFO=494D4B48020100000400000111710110401F000000FA000000000000000000000000000000000000;\r\n";
  x << "a=appversion:1.0\r\n";


2)RTP携带负载中必须规范的一些参数

sequence number:每一次发送数据包必须是递增的

timestamp:对于一帧图像的拆包发送,时间戳必须是一样的,这一点可以通过wireshark抓包可以看出来,对于25fps的帧率,时间戳的时间间隔必须是3600,对于VLC或者一些不太严谨的播放器可能不会造成影响,但是对于萤石NVR必须是规范化的