macos - GStreamer 非法硬件指令

标签 macos clang homebrew gstreamer

我正在尝试学习 GStreamer。我使用的是 macOS 10.13-x86_64。
我开始研究 this教程。

最初我安装了 GStreamer .pkg 文件。
GStreamer 安装在 /Library/Frameworks/GStreamer.framework
我设法编译并运行了教程,但我需要使用 sudo 访问 /Library/Frameworks/GStreamer.framework 目录。

后来发现可以通过homebrew安装GStreamer。
因此,我手动删除了 /Library/Frameworks/GStreamer.framework 并运行以下命令:

brew install gstreamer gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly gst-libav

不幸的是,本教程现在会抛出运行时错误。

./basic-1
[1]    1873 illegal hardware instruction  ./basic-1

我尝试用 lldb 调试错误(我对 lldb 很陌生,几乎什么都不会)。

lldb basic-1
(lldb) target create "basic-1"
Current executable set to 'basic-1' (x86_64).
(lldb) run
Process 2129 launched: '/Users/aleksey/projects/media/gstreamer-dummy/basic-1' (x86_64)
Process 2129 stopped
* thread #14, stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
    frame #0: 0x00007fff3b0e3939 CoreFoundation`__CFRunLoopDeallocate + 537
CoreFoundation`__CFRunLoopDeallocate:
->  0x7fff3b0e3939 <+537>: ud2
    0x7fff3b0e393b <+539>: nopl   (%rax,%rax)

CoreFoundation`__CFRunLoopCleanseSources:
    0x7fff3b0e3940 <+0>:   pushq  %rbp
    0x7fff3b0e3941 <+1>:   movq   %rsp, %rbp
Target 0: (basic-1) stopped.

我不知道该怎么办。

我编译代码

gcc -Wall basic-tutorial-1.c -o basic-1 $(pkg-config --cflags --libs gstreamer-1.0)

我有以下配置

$ pkg-config --cflags --libs gstreamer-1.0
-D_REENTRANT -I/usr/local/Cellar/gstreamer/1.12.3/include/gstreamer-1.0 -I/usr/local/Cellar/glib/2.54.1/include/glib-2.0 -I/usr/local/Cellar/glib/2.54.1/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/pcre/8.41/include -L/usr/local/Cellar/gstreamer/1.12.3/lib -L/usr/local/Cellar/glib/2.54.1/lib -L/usr/local/opt/gettext/lib -lgstreamer-1.0 -lgobject-2.0 -lglib-2.0 -lintl -Wl,-framework -Wl,CoreFoundation

你能帮我解决这个问题吗?有什么问题?

最佳答案

我有同样的问题,我找到了一些答案 here (https://bugzilla.gnome.org/show_bug.cgi?id=790242)。我在这里等待一些额外的评论 https://github.com/sdroege/gstreamer-rs/issues/58

总结:

Remi Achard Apr 11, 2020; 7:55pmRe: Illegal hardware instructions when running basic-tutorial-1 on mac OS 10.15.2 / brew installation

It appears tutorials (at least the first ones) don't work on macOS for some years now.

[Sebastian Dröge (slomo) 2017-11-12 12:41:44 UTC]

See https://github.com/sdroege/gstreamer-rs/issues/58 , same applies to the C tutorials.

The problem is that for osxvideosink and glimagesink we need to run a NSRunLoop on the main thread on macOS. Our patched GLib version does that when you run a GMainLoop (upstream GLib doens't!), but the examples are only using gst_bus_timed_pop_filtered() so that also wouldn't help.

Using a GMainLoop would make the tutorials quite a bit more complicated, more API would have to be introduced, there would always be callbacks, etc.

Not sure what to do about this!

可能的解决方案:

[Kornel 2017-11-12 13:34:16 UTC]

I've managed to get simple examples working by running the example on a thread, and calling CFRunLoopRun() on the main thread. It requires only linking with the foundation.framework.


[更新01] 我能够成功编译并运行 Basic tutorial 12: Streaming .


[更新02]

From: Sebastian Dröge [Dec 29, 2020 11:53am GMT+0100]

It's not that you need a GLib main loop, but macOS requires you to run a NSRunLoop on the main thread for various macOS APIs to work correctly. The GStreamer video sinks use such APIs. The GLib mainloop (from the GLib version shipped with the GStreamer binaries!) runs a NSRunLoop itself for this very reason. This is a limitation on macOS that you'll have to accommodate somehow and is unrelated to GStreamer, and that should probably be mentioned more prominently in the GStreamer documentation.

More info: https://gitlab.freedesktop.org/gstreamer/gst-docs/-/issues/79


其他相关帖子 1 , 3 , 4 .

关于macos - GStreamer 非法硬件指令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46773324/

相关文章:

java - 为什么我的 JavaFX 应用程序不显示 Web 浏览器?

java - OSX Java 系统托盘(菜单栏)

javascript - 当双击广告位于 Flash 中时,自定义滚动无法在 Chrome Mac 上正常工作

c++ - 当一个函数可以被赋予一个 char* 或文字字符串时,声明这个函数的正确方法是什么?

objective-c - 无法用 clang 编译 Objective-C 代码

c - 是否有一个C代码片段,可以在不使用编译器内置函数的情况下有效地计算溢出安全加法?

ruby - 要求 OS X Brew 库安装错误

macos - 错误 : invalid option: --with-default-names

c++ - 如何从函数地址或类中找到 CFBundleRef

ruby - 错误 : You must `brew link pcre' before nginx can be installed