Ffmpeg 在 Electron 沙盒应用程序中被中止

时间:2023-01-28
本文介绍了Ffmpeg 在 Electron 沙盒应用程序中被中止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我有一个 Electron 应用,在 Mac AppStore 上发布,并且是沙盒的.

I have an Electron app, published on the Mac AppStore, and sandboxed.

我正在尝试添加一项新功能,该功能将动态编码/解码视频,以便我可以在 Electron 上下文中流式传输更多视频格式.

I'm trying to add a new feature that will encode/decode videos on the fly so I can stream more video formats in an Electron context.

我正在使用 fluent-ffmpeg 和一个 ffmpeg的静态执行.

I'm using fluent-ffmpeg and a static exec of ffmpeg.

一切都很棒,我已将沙盒应用程序上传到 Apple,但被拒绝了,因为 ffmpeg 默认使用使用非公共 API 的安全传输协议,这是他们发送给我的拒绝信息:

Everything works awesomely, I've uploaded the sandboxed app to Apple, and got rejected because ffmpeg is using by default a secure transport protocol which is using non-public API, this is what they've sent me with the rejection:

您的应用使用或引用以下非公共 API:

Your app uses or references the following non-public API(s):

'/System/Library/Frameworks/Security.framework/Versions/A/Security'

'/System/Library/Frameworks/Security.framework/Versions/A/Security'

: SecIdentityCreate

: SecIdentityCreate

好的,经过大量调查,看来我必须使用 --disable-securetransport 标志自己编译 ffmpeg.很简单,我使用与我下载的静态构建相同的配置来完成它,只需添加新标志.

Alright, after much investigation, it appears that I have to compile ffmpeg myself with a --disable-securetransport flag. Easy enough, I do it using the same config as the static build I've downloaded simply adding the new flag.

我设法安装了所有需要的依赖项,除了 libxavs,我猜没什么大不了的,只需从配置命令中删除它的标志:

I manage to install every dependencies needed, except libxavs, no big deal I guess and simply remove its flag from the configure command:

./configure 
--cc=/usr/bin/clang 
--prefix=/opt/ffmpeg 
--extra-version=tessus 
--enable-avisynth 
--enable-fontconfig 
--enable-gpl 
--enable-libass 
--enable-libbluray 
--enable-libfreetype 
--enable-libgsm 
--enable-libmodplug 
--enable-libmp3lame 
--enable-libopencore-amrnb 
--enable-libopencore-amrwb 
--enable-libopus 
--enable-libsnappy 
--enable-libsoxr 
--enable-libspeex 
--enable-libtheora 
--enable-libvidstab 
--enable-libvo-amrwbenc 
--enable-libvorbis 
--enable-libvpx 
--enable-libwavpack 
--enable-libx264 
--enable-libx265 
--enable-libxvid 
--enable-libzmq 
--enable-libzvbi 
--enable-version3 
--pkg-config-flags=--static 
--disable-securetransport 
--disable-ffplay

使用新的 ffmpeg exec,一切仍按预期工作.但是,一旦我对应用程序进行打包、签名和沙盒化,一旦我尝试启动 ffmpeg 并抛出此错误,它就会停止工作:

With the new ffmpeg exec, everything still works as expected. But once I'm packaging, signing and sandboxing the app, ffmpeg stops working as soon as I try to launch it throwing this error:

An error occurred ffmpeg was killed with signal SIGABRT Error: ffmpeg was killed with signal SIGABRT
    at ChildProcess.eval (webpack:///../node_modules/fluent-ffmpeg/lib/processor.js?:180:22)
    at emitTwo (events.js:125:13)
    at ChildProcess.emit (events.js:213:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)

我试图删除 --disable-securetransport 标志,看看它是否会弄乱某些东西,同样的结果.

I've tried to remove the --disable-securetransport flag, see if it could have messed with something, same result.

我尝试在 Linux 机器上编译,只是想看看它是否有帮助,同样的事情.

I've tried to compile on a Linux machine, just to see if it could help, same thing.

一旦我使用自定义编译的 exec,它就不能在沙箱中工作,但是当使用静态的时,一切正常(在我 xattr 之后,因为 它在沙盒中被隔离和阻止).

As soon as I'm using my custom compiled exec it doesn't work in the sandbox, but when using the static one, everything is ok (after I xattr it, because it's quarantined and blocked in sandbox).

我注意到的唯一一件奇怪的事情是我的自定义编译只有 20 个月左右,而我下载的静态安装是 43 个月.

The only thing I've noticed that seems odd is that my custom compilation is only 20mo or so, when the static install I've downloaded is 43mo.

我真的被这个困住了.

推荐答案

所以我终于能够编译我的静态 ffmpeg 可执行文件了.

So I finally was able to compile my static ffmpeg executable.

感谢这个答案,我找到了我的解决方案.

I've found my solution thanks to this answer.

显然,OSX 的动态库位于 /usr/local/bin 中,它们优先于其他所有内容.因此,即使您尝试将 ffmpeg 编译为静态的,它也无法与这些库一起使用.

Apparently, OSX has dynamic libraries located in /usr/local/bin which take precedence over everything else. So even if you try to compile your ffmpeg to be static, it won't work with these libraries on the way.

一旦我删除了所有这些 /usr/local/bin/*.dylib,我的构建就变成了完全静态的并且在沙盒中完美运行.

Once I've removed all those /usr/local/bin/*.dylib my build became fully static and worked perfectly in the sandbox.

这篇关于Ffmpeg 在 Electron 沙盒应用程序中被中止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

上一篇:在 Electron 中找不到模块 下一篇:WebkitSpeechRecognition 在 Electron 中返回网络错误

相关文章

最新文章