首页 > 解决方案 > 如何从 Gstreamer 管道中逐帧获取视频流?(没有 OpenCV)

问题描述

我正在做一个 Gstreamer 项目,我需要从 RTSP 流中提取图像。我可以使用 multifilesink 保存来自 gst_parse_launch 的图像,但无法将“侦听器”添加到管道以获取缓冲区并从中提取图像。

到目前为止我所拥有的:

pipeline = gst_parse_launch("-e -v rtspsrc location="IPADDRESS" ! rtph264depay ! h264parse ! 
decodebin ! jpegenc ! appsink name=sink",
        NULL);
bus = gst_element_get_bus(pipeline);
gst_element_set_state(pipeline, GST_STATE_PLAYING);

bus = gst_element_get_bus(pipeline);


GstElement *sink = gst_bin_get_by_name(GST_BIN(pipeline), "sink");
if (!sink) {
    printf("sink is NULL\n");
    exit(1);
}

GstAppSink *appsink = GST_APP_SINK(sink);
if (!appsink) {
    printf("appsink is NULL\n");
    exit(1);
}

GstSample *sample = gst_app_sink_pull_sample(appsink);
if (!sample) {
    printf("sample is NULL\n");
    exit(1);
}

GstBuffer *buffer = gst_sample_get_buffer(sample);
GstMapInfo map;

gst_buffer_map(buffer, &map, GST_MAP_READ);

`

如何在不使用 OpenCV 的情况下做到这一点?(仅获取图像的字节)以及如何循环遍历管道中缓冲的帧?

先感谢您。

标签: cgstreamerpipelinertsp

解决方案


推荐阅读