目录
4、easyplayer-rtsp.exe播放器播放RTSP数据流
将H264数据流直接推流的优点是,省去了RTP打包的过程,数据传输更快,缺点是单包数据不能超过65507,否则会将丢弃掉
1、将H264数据流UDP推流
在虚拟机Ubuntu中打开一个命令行,然后输入命令:
gst-launch-1.0 v4l2src device=/dev/video0 ! videoconvert ! 'video/x-raw,format=(string)NV12,width=640,height=480,framerate=(fraction)30/1' ! queue ! x264enc ! udpsink host=127.0.0.1 port=5000 sync=false
2、UDP client拉流,然后RTSP传输
在虚拟机Ubuntu中打开另一个命令行,然后输入命令:
/test-launch "( udpsrc port=5000 caps= \"video/x-h264, stream-format=(string)byte-stream\" ! rtph264pay name=pay0 )"
其中test-launch是gstreamer RTSP推流模块,此模块的下载、编译参考如下链接:
gstreamer USB摄像头RTSP推流_pengyouhai的专栏-CSDN博客
3、注意事项
由于是直接将H264进行推流,数据流是直接通过socket发送出去的,因此H264单包数据量不能超过65507,否则会导致数据溢出。
例如:第一条命令,将数据流编码成H264时,码率默认是2Mbit/s,如果将码率设为10Mbit/s,将会出现数据溢出:
gst-launch-1.0 v4l2src device=/dev/video0 ! videoconvert ! 'video/x-raw,format=(string)NV12,width=640,height=480,framerate=(fraction)30/1' ! queue ! x264enc bitrate=10240 ! udpsink host=127.0.0.1 port=5000 sync=false
4、easyplayer-rtsp.exe播放器播放RTSP数据流
其中:192.168.5.136是虚拟机Ubuntu的IP