Gstreamer进程在OSX上以退出码132结束,使用Hello World示例



当我运行Gstreamers python API的Hello World教程时,我得到以下错误:

GST_DEBUG=3 python tutorial_1.py
0:00:01.787091000 98337 0x7fde78071920 ERROR              gldisplay gstgldisplay_cocoa.m:171:gst_gl_display_cocoa_setup_nsapp: Custom NSApp initialization failed
0:00:01.787178000 98337 0x7fde78071920 ERROR                glutils gstglutils.c:229:gst_gl_element_propagate_display_context:<sink> Could not get GL display connection
0:00:01.788032000 98337 0x7fde78071920 WARN                 playbin gstplaybin2.c:4757:autoplug_select_cb:<playbin0> Could not activate sink glimagesink
0:00:01.792032000 98337 0x7fde78071920 FIXME           videodecoder gstvideodecoder.c:1052:gst_video_decoder_drain_out:<vp8dec0> Sub-class should implement drain()
0:00:01.859639000 98337 0x7fde78071980 FIXME           videodecoder gstvideodecoder.c:1052:gst_video_decoder_drain_out:<vp8dec0> Sub-class should implement drain()
zsh: illegal hardware instruction  GST_DEBUG=3 python tutorial_1.py

但是当我在终端中运行Gstreamer命令时,基本上具有相同的目的,窗口正确打开,没有问题:

gst-launch-1.0 -v playbin uri=https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm

寻找解决方案或推动正确的方向来解决这个问题。

环境:

  • 硬件:
    • 机型名称:MacBook Pro
    • 型号标识:macbookpro13,3
    • 处理器名称:四核Intel Core i7
    • 处理器速度:2.7 GHz
  • 操作系统:
    • 系统版本:macOS 11.6 (20G165)
    • 内核版本:Darwin 20.6.0
  • GStreamer 1.18.4
  • pygobject 3.42.0
  • python 3.9.7

教程代码:

#!/usr/bin/env python3
import sys
import gi
gi.require_version('GLib', '2.0')
gi.require_version('GObject', '2.0')
gi.require_version('Gst', '1.0')
from gi.repository import Gst, GObject, GLib
pipeline = None
bus = None
message = None
# initialize GStreamer
Gst.init(sys.argv[1:])
# build the pipeline
pipeline = Gst.parse_launch(
"playbin uri=https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm"
)
# start playing
pipeline.set_state(Gst.State.PLAYING)
# wait until EOS or error
bus = pipeline.get_bus()
msg = bus.timed_pop_filtered(
Gst.CLOCK_TIME_NONE,
Gst.MessageType.ERROR | Gst.MessageType.EOS
)
# free resources
pipeline.set_state(Gst.State.NULL)

这可能是由于MacOS上与OpenGL相关的一些要求。请注意,在你的例子中,playbin将尝试打开一些OpenGL窗口来显示里面的视频。如需更多信息,请访问此链接。

下面是一个简单的例子,如何在c++中使用hello world应用程序解决这个问题:

#include <gst/gst.h>
#include <thread>
#include <CoreFoundation/CoreFoundation.h>
int
main (int argc, char *argv[])
{
std::thread t([&]{
GstElement *pipeline;
GstBus *bus;
GstMessage *msg;
/* Initialize GStreamer */
gst_init(&argc, &argv);
/* Build the pipeline */
pipeline =
gst_parse_launch
("playbin uri=https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm",
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,
static_cast<GstMessageType>(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);
});
CFRunLoopRun();
t.join();
return 0;
}

构建和运行:

$ clang++ -std=c++17  -ggdb -O0  gst.cpp $(pkg-config --cflags --libs gstreamer-1.0) -framework CoreFoundation
$ ./a.out

窗口只能在GMainLoop上创建。查看https://gstreamer.freedesktop.org/documentation/tutorials/basic/streaming.html?gi-language=c

相关内容

  • 没有找到相关文章