我想通过gstreamer捕获视频帧并在我的应用程序上显示(使用Qt),但是遇到一些问题:
当我尝试使用GstAppSink(gst_app_sink_pull_sample)时,它一直返回NULL,这是我不理解的。我可以完美地使用终端(gst-launch-1.0)流式传输视频。
下面是我的代码:
void gstreamer::openStream()
{
pipeline = gst_parse_launch ("rtspsrc location=rtsp://192.168.10.123 ! rtph264depay ! h264parse ! queue ! avdec_h264 ! xvimagesink sync=false async=false appsink name=mysink", NULL);
GstElement* sink = gst_bin_get_by_name(GST_BIN(pipeline), "mysink");
GstAppSink* appsink = GST_APP_SINK(sink);
if(!appsink)
{
qDebug() << "get app sink failed";
}
else
{
qDebug() << "app sink pass";
mAppSink = appsink;
openSample();
}
}
void gstreamer::openSample()
{
if(!mAppSink)
{
qDebug() << "appsink failed";
}
GstSample* gstSample = gst_app_sink_pull_sample(mAppSink);
if(gstSample == NULL)
{
qDebug() << "sample failed ";
}
else{
qDebug() << "sample pass";
}
GstBuffer* buffer = gst_sample_get_buffer(gstSample);
if(!buffer)
{
qDebug() << "buffer fail";
}
GstMapInfo map;
gst_buffer_map(buffer, &map, GST_MAP_READ);
QImage image = QImage((map.data), 320, 240, QImage::Format_RGB888);
emit sendFrame(image);
}
我试图在网络上找到该问题,但是几乎没有任何链接。
答案 0 :(得分:-1)
尝试将管道更改为 “ rtspsrc位置= rtsp://192.168.10.123!rtph264depay!h264parse!发球名称= my_tee!队列!avdec_h264!xvimagesink sync = false my_tee。!队列!appsink async = false name = mysink”