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

posted @   thomas_blog  阅读(5676)  评论(1编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示