1.软件版本:
2.下载Gstreamer源码:
git clone https://github.com/GStreamer/gst-plugins-bad
查看本机gstreamer版本:
gst-launch-1.0 –version
切换插件版本与本机源码版本一致:
cd gst-plugins-bad
git branch -b 1.14.5 (当前我的版本)
chmod 777 autogen.sh
./autogen.sh
3.编译安装:
解压 Video_Codec_SDK_11.1.5 执行下面命令:NVIDIA VIDEO CODEC SDK
Video_Codec_SDK_11.1.5 执行下面命令:
sudo cp Interface/* /usr/local/cuda/include
sudo cp Lib/linux/stubs/x86_64/* /usr/local/cuda/lib64/stubs
cd gst-plugins-bad
NVENCODE_LIBS="-L/usr/local/cuda/lib64/stubs" NVENCODE_CFLAGS="-I/usr/local/cuda/include" ./configure --enable-nvenc --enable-openh264 --with-cuda-prefix="/usr/local/cuda-11.7"
(当前我的cuda版本为11.7)
cd nvenc
make -j4
sudo make install
添加环境变量:
echo export GST_PLUGIN_PATH="/usr/local/lib/gstreamer-1.0" >> ~/.bashrc
4.验证插件是否安装成功:
gst-inspect-1.0 nvh264enc
rtp推拉流测试
拉流端:
gst-launch-1.0 udpsrc port=9876 ! application/x-rtp,encoding-name=H264,payload=96 ! rtph264depay ! h264parse ! avdec_h264 ! queue ! videoscale ! videoconvert ! ximagesink sync=false -e
推流端:
gst-launch-1.0 -v v4l2src device=/dev/video0 ! video/x-raw,format=YUY2,width=640,height=480,framerate=30/1 ! videoconvert ! nvh264enc ! video/x-h264, stream-format=byte-stream ! rtph264pay ! udpsink host=127.0.0.1 port=9876