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

Ffmpeg gets aborted in an Electron sandboxed application(Ffmpeg 在 Electron 沙盒应用程序中被中止)
本文介绍了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 沙盒应用程序中被中止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转
Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
Ordinals in words javascript(javascript中的序数)
getFullYear returns year before on first day of year(getFullYear 在一年的第一天返回前一年)