赞
踩
部分内容来自:
https://blog.csdn.net/cau_weiyuhu/article/details/128291577
https://huaweicloud.csdn.net/635642c3d3efff3090b5c9fc.html
看到这几篇文章,正好现在有USB相机,打算自己尝试一下,但是发现没那么简单,首先就是他们都是使用了老版的 1.8版本,那么我想使用1.16版本的尝试,刚开始失败了,于是自己摸索了一下,最终实验成功,并且发现了一些延时相关的内容。
gstreamer和使用USB相机那些内容参考前文。
从https://github.com/GStreamer/gst-rtsp-server/ 下载一个版本 ,例如参考文章的1.8,我下载的是较新版本的1.16。记得下载源码压缩包,比如我 gst-rtsp-server-1.16.0.tar.xz
需要安装更高的cmake,这个自己百度源码安装,很简单。
安装相关库,命令: sudo apt install gtk-doc-tools
cd gst-rtsp-server-1.16.0
./autogen.sh
sudo make
sudo make install
gcc test-launch.c -o test-launch $(pkg-config --cflags --libs gstreamer-rtsp-server-1.0 gstreamer-1.0)
./test-launch "( videotestsrc ! x264enc ! rtph264pay name=pay0 pt=96 )"
./test-launch --gst-debug-level=3 "( v4l2src device=/dev/video0 ! videoconvert! videoscale ! video/x-raw, width=640, height=480, framerate=30/1 ! queue ! x264enc bitrate=10240 ! rtph264pay name=pay0 pt=96 )"
使用VLC播放,或者使用gstreamer播放, gst-launch-1.0 playbin uri=rtsp://127.0.0.1:8554/test
测试发现,有3秒的延迟:
./test-launch "( v4l2src device=/dev/video0 ! videoconvert! videoscale ! video/x-raw, width=2592, height=600, framerate=30/1 ! timeoverlay ! tee name=vsrc vsrc. ! queue ! videoconvert ! ximagesink vsrc. ! queue ! x264enc tune=zerolatency ! rtph264pay name=pay0 pt=96 )"
发现延迟少了很多,大概只有1秒。
最终测试出来,是因为x264enc后面加了 bitrate=10240,才会如此的慢,适当调大会好一些,或者把这个参数给去掉,系统会自动设置比特率,这样就快了很多。
./test-launch "( v4l2src device=/dev/video0 ! videoconvert! videoscale ! video/x-raw, framerate=30/1 ! timeoverlay ! tee name=vsrc vsrc. ! queue ! videoconvert ! ximagesink vsrc. ! queue ! x264enc tune=zerolatency ! rtph264pay name=pay0 pt=96 )"
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。