問題描述
我有一個 Electron 應用,在 Mac AppStore 上發(fā)布,并且是沙盒的.
I have an Electron app, published on the Mac AppStore, and sandboxed.
我正在嘗試添加一項新功能,該功能將動態(tài)編碼/解碼視頻,以便我可以在 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的靜態(tài)執(zhí)行.
I'm using fluent-ffmpeg and a static exec of ffmpeg.
一切都很棒,我已將沙盒應用程序上傳到 Apple,但被拒絕了,因為 ffmpeg 默認使用使用非公共 API 的安全傳輸協(xié)議,這是他們發(fā)送給我的拒絕信息:
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
好的,經(jīng)過大量調(diào)查,看來我必須使用 --disable-securetransport
標志自己編譯 ffmpeg.很簡單,我使用與我下載的靜態(tài)構建相同的配置來完成它,只需添加新標志.
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,它就不能在沙箱中工作,但是當使用靜態(tài)的時,一切正常(在我 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 個月左右,而我下載的靜態(tài)安裝是 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.
我真的被這個困住了.
推薦答案
所以我終于能夠編譯我的靜態(tài) ffmpeg 可執(zhí)行文件了.
So I finally was able to compile my static ffmpeg executable.
感謝這個答案,我找到了我的解決方案.
I've found my solution thanks to this answer.
顯然,OSX 的動態(tài)庫位于 /usr/local/bin
中,它們優(yōu)先于其他所有內(nèi)容.因此,即使您嘗試將 ffmpeg 編譯為靜態(tài)的,它也無法與這些庫一起使用.
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
,我的構建就變成了完全靜態(tài)的并且在沙盒中完美運行.
Once I've removed all those /usr/local/bin/*.dylib
my build became fully static and worked perfectly in the sandbox.
這篇關于Ffmpeg 在 Electron 沙盒應用程序中被中止的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!