无法使用 gst_element_make_from_uri 播放 uri

发布于 2024-09-09 20:45:47 字数 911 浏览 7 评论 0原文

我需要传输 RTSP / HTTP 流,当我使用 source = gst_element_make_from_uri(); 创建元素源时,它不起作用。有人使用 gstreamer 来传输 RTSP / HTTP 流吗?

source   = gst_element_make_from_uri (GST_URI_SRC,"http://76.73.90.27:80/" ,NULL);
decoder = gst_element_factory_make ("mad",      "mad-decoder"); 
sink     = gst_element_factory_make ("alsasink", "audio-output");
g_object_set (G_OBJECT (source), "location", argv[1], NULL);
gst_element_set_state (pipeline, GST_STATE_NULL);

bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);

gst_bin_add_many (GST_BIN (pipeline),
                  source, decoder,sink, NULL);

gst_element_link_many (source, decoder, sink, NULL);

gst_element_set_state (pipeline, GST_STATE_PLAYING);

g_main_loop_run (loop);
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (GST_OBJECT (pipeline));

I need to stream RTSP / HTTP stream and when I create an element source using source = gst_element_make_from_uri(); it doesn't work. Has anybody used gstreamer for streaming RTSP / HTTP streams?

source   = gst_element_make_from_uri (GST_URI_SRC,"http://76.73.90.27:80/" ,NULL);
decoder = gst_element_factory_make ("mad",      "mad-decoder"); 
sink     = gst_element_factory_make ("alsasink", "audio-output");
g_object_set (G_OBJECT (source), "location", argv[1], NULL);
gst_element_set_state (pipeline, GST_STATE_NULL);

bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);

gst_bin_add_many (GST_BIN (pipeline),
                  source, decoder,sink, NULL);

gst_element_link_many (source, decoder, sink, NULL);

gst_element_set_state (pipeline, GST_STATE_PLAYING);

g_main_loop_run (loop);
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (GST_OBJECT (pipeline));

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

断爱 2024-09-16 20:45:47

您指向了错误的 IP 地址。该 IP 是普通的网络服务器,而不是流媒体广播。尝试在音乐播放器中播放广播电台的 .m3u 并查看它实际播放的地址。

相反,尝试运行 gst-launch souphttpsrc location=http://76.73.52.173/ !解码器!自动音频接收器。您可以使用 gst_parse_launch() 在程序中使用这些相同的字符串,并且您的程序会短得多。

You are pointing at the wrong IP address. That IP is a normal web server, not streaming radio. Try playing the radio station's .m3u in a music player and see which address it actually plays.

Instead, try running gst-launch souphttpsrc location=http://76.73.52.173/ ! decodebin ! autoaudiosink. You can use gst_parse_launch() to use these same strings in your program, and your program will be much shorter.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文