我正在尝试在 Mac Apple Store (mas) 上发布 Electron 应用程序,我的 Electron 应用程序使用 ffmpeg 来渲染视频。为了在 mac apple store 上发布我的应用程序,它需要被沙盒化,并且默认情况下 ffmpeg 会调用外部库,因此我需要静态构建 ffmpeg 并将其与我的应用程序打包。我的代码在“mas-ffmpeg-fix”分支上:https://github.com/MartinBarker/digify/tree/mas-ffmpeg-fix
我的静态 ffmpeg 构建在我构建我的应用程序之前工作,但在运行 electron-builder build --mac
之后, ffmpeg 可执行文件现在失败并显示 Illegal instruction: 4
这是构建/打包/提交我的应用程序到 mac 苹果商店的完整时间线,以及错误首次出现的位置:
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg-mac && cd ffmpeg-mac && ./configure pkg_config='pkg-config --static' --pkg-config-flags='--static' --libdir=/usr/local/lib --extra-version=ntd_20150128 --disable-shared --disable-lzma --enable-gpl --enable-pthreads --enable-nonfree --enable-libass --enable-libfdk-aac --enable-libmp3lame --enable-libx264 --enable-static --enable-filters --enable-runtime-cpudetect && make && cd ..
将 ffmpeg 与 Electron UI 一起使用:有效
通过命令行命令使用 Ffmpeg:
/Users/martinbarker/Documents/projects/digify-new/ffmpeg-mac/ffmpeg -h
作品ffmpeg 命令行检查:
/Users/martinbarker/Documents/projects/digify-new/dist/mas/Digify.app/Contents/Resources/ffmpeg -h
非法指令:4
这是错误出现的第一个地方,在构建我的 mac mac-apple-store 应用程序后,ffmpeg 失败并出现此错误。
view .sh file here
此应用程序在商店中发布后,如果您下载它并尝试使用 Electron UI 运行 ffmpeg 命令,则会失败并显示以下错误:
/Applications/Digify.app/Contents/Resources/app.asar/node_modules/execa/lib/error.js:59 Uncaught (in promise) Error: Command failed with exit code 1: /Applications/Digify.app/Contents/Resources/ffmpeg -i /Users/martinbarker/Downloads/Felix Lebarty - Bobo/01. Bobo.mp3 -y -filter_complex concat=n=1:v=0:a=1 -c:a libmp3lame -b:a 320k /Users/martinbarker/Downloads/Felix Lebarty - Bobo/output-064237.mp3
ffmpeg version N-101191-g51a9f487ae-ntd_20150128 Copyright (c) 2000-2021 the FFmpeg developers
built with Apple LLVM version 10.0.1 (clang-1001.0.46.4)
configuration: pkg_config='pkg-config --static' --pkg-config-flags=--static --libdir=/usr/local/lib --extra-version=ntd_20150128 --disable-shared --disable-lzma --enable-gpl --enable-pthreads --enable-nonfree --disable-libass --enable-libfdk-aac --enable-libmp3lame --enable-libx264 --enable-static --enable-filters --enable-runtime-cpudetect
libavutil 56. 65.100 / 56. 65.100
libavcodec 58.125.100 / 58.125.100
libavformat 58. 68.100 / 58. 68.100
libavdevice 58. 12.100 / 58. 12.100
libavfilter 7.107.100 / 7.107.100
libswscale 5. 8.100 / 5. 8.100
libswresample 3. 8.100 / 3. 8.100
libpostproc 55. 8.100 / 55. 8.100
[mp3 @ 0x7feeae809c00] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from '/Users/martinbarker/Downloads/Felix Lebarty - Bobo/01. Bobo.mp3':
Metadata:
comment :
album : Bobo
artist : Felix Lebarty
title : Funkytown Eklablog
genre : Boogie
date : 1984
Duration: 00:05:19.53, start: 0.000000, bitrate: 320 kb/s
Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 320 kb/s
/Users/martinbarker/Downloads/Felix Lebarty - Bobo/output-064237.mp3: Operation not permitted
at makeError (/Applications/Digify.app/Contents/Resources/app.asar/node_modules/execa/lib/error.js:59)
at handlePromise (/Applications/Digify.app/Contents/Resources/app.asar/node_modules/execa/index.js:114)
at async file:/Applications/Digify.app/Contents/Resources/app.asar/src/js/newindex.js:1162
Command failed with exit code 1: Operation not permitted
最佳答案
在 Electron 中,您需要先使用文件浏览器窗口选择输出文件夹目录,然后 ffmpeg 才能写入任何文件
关于macos - Electron ffmpeg mas 构建 "Illegal instruction: 4",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66286440/