如何解决由帧大小引起的GStreamer H.264编码的RTP流失真
我的C ++代码库中有以下管道拆分:
_cap.open(
" videotestsrc ! "
" video/x-raw,width=640,height=480,framerate=60/1 ! "
" clockoverlay halignment=left valignment=top shaded-background=true font-desc=\"Sans,36\" ! "
" videoconvert ! appsink"
);
LOG_INFO("Opening H264 GStreamer writer object at "
<< _host << ":" << _port << " with " << horizontal_resolution
<< "x" << vertical_resolution << "p@" << fps << "fps"
<< "(color=" << is_color << ")");
const std::string filename{
" appsrc is-live=true ! videoconvert ! "
" x264enc bitrate=1000 ! video/x-h264,profile=baseline ! rtph264pay config-interval=1 pt=96 ! queue ! "
" udpsink host=" + _host + " port=" + _port
};
writer.open(
filename,cv::CAP_GSTREAMER,fps,cv::Size{horizontal_resolution,vertical_resolution},is_color
);
我在测试期间使用videotestsrc
作为cv::VideoCapture
来模拟数据,并使用cv::VideoWriter
进行RTP流传输。在我的主循环中,我只是从cv::VideoCapture
捕获帧并将其馈送到cv::VideoWriter
。
我使用VLC和以下SDP文件捕获RTP流:
v=0
m=video 5000 RTP/AVP 96
c=IN IP4 127.0.0.1
a=rtpmap:96 H264/90000
直觉上我知道框架的预期大小存在问题,但是由于不熟悉GStreamer,所以我不知道该怎么做。
我尝试使用以下方法缩放管道内部的图像:
gst-launch-1.0 videotestsrc ! \
video/x-raw,width=1920,height=1080,framerate=60/1 ! \
clockoverlay halignment=left valignment=top shaded-background=true font-desc=\"Sans,36\" ! \
videoconvert ! videoscale ! video/x-raw,width=320,height=240 ! \
videoconvert ! x264enc bitrate=1000 ! video/x-h264,profile=baseline ! rtph264pay config-interval=1 pt=96 ! \
queue ! udpsink host=127.0.0.1 port=5000
可作为独立管道使用,但如果将其放入cv::VideoWriter
内则无法使用:
LOG_INFO("Opening H264 GStreamer writer object at "
<< _host << ":" << _port << " with " << horizontal_resolution
<< "x" << vertical_resolution << "p@" << fps << "fps"
<< "(color=" << is_color << ")");
const std::string filename{
" appsrc is-live=true ! "
" videoconvert ! videoscale ! video/x-raw,height=240 ! "
" videoconvert ! x264enc bitrate=1000 ! video/x-h264,is_color
);
目前,我正在使用cv::resize
调整管道外部的框架大小,但是我想调整管道内部的框架大小。我该怎么办?
SW版本信息:
- OpenCV 4.2.0
- GStreamer 1.16.1
- VLC 3.0.8
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。