AI视觉处理--gstreamer应用
术语:
过滤器(filters)
转换器(convertors)
分流器(demuxers)
整流器(muxers)
编解码器(codecs)
检查支持类型:
$ gst-inspect-1.0
通过Opencv保存视频
// 组织gst管道字符串
QString gst_str = "appsrc \
! videoconvert \
! nvvidconv \
! nvv4l2h264enc profile=4 bitrate=100000000 \
! h264parse \
! queue2 \
! flvmux \
! filesink location=/media/sda/data/test.mp4";
vwriter = new VideoWriter(gst_str, 0, fps, (1280, 720));
vwriter->write(img_mat); // 保存视频流
profile - 设置视频质量 0 - 最低, 4 - 最高
bitrate - 设置视频比特率
rtmp推流:
char gst_str[]= "appsrc \
! videoconvert \
! nvvidconv \
! omxh264enc bitrate=400000 \
! video/x-h264,stream-format=(string)byte-stream \
! h264parse \
! flvmux \
! rtmpsink location=rtmp://127.0.0.1/hls/123";
vwriter = new VideoWriter(gst_str, 0, fps, Size(rtmpWidth, rtmpHeight));
从摄像机读入至应用程序:
nvarguscamerasrc \
! video/x-raw(memory:NVMM), width=(int)640, height=(int)480, format=(string)NV12, framerate=(fraction)60/1 \
! nvvidconv flip-method=0 \
! video/x-raw, width=(int)640, height=(int)480, format=(string)BGRx \
! videoconvert \
! video/x-raw, format=(string)BGR \
! appsink
appsink - 输出至应用程序
从标准备摄像机设备推流视频:
$ gst-launch-1.0 v4l2src device="/dev/video0" \
! video/x-raw \
! videoconvert \
! omxh264enc \
! h264parse \
! flvmux \
! rtmpsink location="rtmp://192.168.10.106/hls/123"
本地文件推流至RTMP服务器:
$ gst-launch-1.0 -v uridecodebin name=uridec uri=file:///media/sda/data/123.mp4 \
! videoconvert \
! omxh264enc \
! h264parse \
! flvmux \
! rtmpsink location="rtmp://192.168.10.151/hls/123"
播放MP3:
$ gst-launch-1.0 filesrc location=/mnt/hgfs/code/gst/cd.mp3 ! decodebin ! audioconvert ! alsasink
播放MP4:
$ gst-launch-1.0 filesrc location=test.mp4 ! decodebin ! autovideosink
输入设备:
标准摄像机: v4l2src device="/dev/video0"
应用程序: appsrc
输出设备:
rtmp服务器:
rtmpsink location="rtmp://192.168.10.151/hls/stream"
保存至文件:filesink location="/media/movie/test.mp4"
应用程序:appsink
https://blog.csdn.net/xiaonuo911teamo/article/details/110958685
https://cloud.tencent.com/developer/article/1676143
gst-launch-1.0 v4l2src ! xvimagesink
gst-launch-1.0 videotestsrc ! 'video/x-raw, width=(int)1280,height=(int)720,format(string)I420,framerate=(fraction)30/1' ! nveglglessink -e
filesrc - 从文件输入
appsrc - 应用程序输入
alsasink - alsa声卡输出
filesink - 文件输出
rtmpsink - RTMP输出