GStreamer rtsp拉流播放


使用命令拉流播放測試

gst-launch-1.0 playbin uri=rtsp://172.17.0.8/1.264

正常效果如下:

image

如果報如下錯誤:

Your GStreamer installation is missing a plug-in. Additional debug info:

解決辦法:

sudo apt-get install ubuntu-restricted-extras

代碼拉流

#include <gst/gst.h>

int main(int argc, char *argv[])
{
    GstElement *pipeline;
    GstBus *bus;
    GstMessage *msg;

    /* Initialize GStreamer */
    gst_init (&argc, &argv);

    /* Build the pipeline */
    pipeline = gst_parse_launch ("playbin uri=rtsp://172.17.0.8/1.264", NULL);

    /* Start playing */
    gst_element_set_state (pipeline, GST_STATE_PLAYING);

    /* Wait until error or EOS */
    bus = gst_element_get_bus (pipeline);
    msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS);

    /* Free resources */
    if (msg != NULL)
    gst_message_unref (msg);
    gst_object_unref (bus);
    gst_element_set_state (pipeline, GST_STATE_NULL);
    gst_object_unref (pipeline);

    return 0;
}

編譯:

gcc main.c -o main -Wall $(pkg-config --cflags --libs gstreamer-1.0)

如果報如下錯誤:

No package 'gstreamer-1.0' found
main.c:1:23: fatal error: gst/gst.h: No such file or directory

解決辦法:

sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev

正常運行效果同上

./main

本文用到

live555服務器live555MediaServer


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM