Add documentation about ffmpeg
https://alexandercleasby.dev/blog/use-ffmpeg-electron
This commit is contained in:
parent
7b1b6bf88f
commit
bb865a7b15
3 changed files with 31 additions and 1 deletions
|
@ -31,6 +31,13 @@ mac:
|
|||
hardenedRuntime: true
|
||||
x64ArchFiles: Contents/Resources/ggmlclip-mac
|
||||
afterSign: electron-builder-notarize
|
||||
# When Electron packages our node_modules, they go into the ASAR archive. This
|
||||
# is not what we want for the FFMPEG binaries though, and instead put them
|
||||
# outside of the ASAR archive so that we can get at a direct path to these files
|
||||
# when trying to run it.
|
||||
#
|
||||
# The filtering by `${os}` and `${arch}` is to include only the binaries for the
|
||||
# os/arch combination that we're bundling.
|
||||
asarUnpack:
|
||||
- node_modules/ffmpeg-static/bin/${os}/${arch}/ffmpeg
|
||||
- node_modules/ffmpeg-static/index.js
|
||||
|
|
|
@ -385,7 +385,7 @@ setupLogging();
|
|||
// [Note: Transferring large amount of data over IPC]
|
||||
//
|
||||
// Electron's IPC implementation uses the HTML standard Structured Clone
|
||||
// Algorithm to serialize objects passed between processes. [1]
|
||||
// Algorithm to serialize objects passed between processes.
|
||||
// https://www.electronjs.org/docs/latest/tutorial/ipc#object-serialization
|
||||
//
|
||||
// In particular, both ArrayBuffer and the web File types are eligible for
|
||||
|
@ -406,6 +406,9 @@ setupLogging();
|
|||
// copying, the IPC should be fast enough for even moderately large data:
|
||||
// https://github.com/electron/electron/issues/1948#issuecomment-864191345
|
||||
//
|
||||
// The main problem with transfering large amounts of data is potentially
|
||||
// running out of memory, causing the app to crash as it copies it over across
|
||||
// the processes.
|
||||
contextBridge.exposeInMainWorld("ElectronAPIs", {
|
||||
exists,
|
||||
checkExistsAndCreateDir,
|
||||
|
|
|
@ -20,6 +20,26 @@ function getFFmpegStaticPath() {
|
|||
return pathToFfmpeg.replace("app.asar", "app.asar.unpacked");
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a ffmpeg command
|
||||
*
|
||||
* [Note: FFMPEG in Electron]
|
||||
*
|
||||
* There is a wasm build of FFMPEG, but that is currently 10-20 times slower
|
||||
* that the native build. That is slow enough to be unusable for our purposes.
|
||||
* https://ffmpegwasm.netlify.app/docs/performance
|
||||
*
|
||||
* So the alternative is to bundle a ffmpeg binary with our app. e.g.
|
||||
*
|
||||
* yarn add fluent-ffmpeg ffmpeg-static ffprobe-static
|
||||
*
|
||||
* (we only use ffmpeg-static, the rest are mentioned for completeness' sake).
|
||||
*
|
||||
* Interestingly, Electron already bundles an ffmpeg library (it comes from the
|
||||
* ffmpeg fork maintained by Chromium).
|
||||
* https://chromium.googlesource.com/chromium/third_party/ffmpeg
|
||||
* https://stackoverflow.com/questions/53963672/what-version-of-ffmpeg-is-bundled-inside-electron
|
||||
*/
|
||||
export async function runFFmpegCmd(
|
||||
cmd: string[],
|
||||
inputFilePath: string,
|
||||
|
|
Loading…
Add table
Reference in a new issue