Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build-prebuilds-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ jobs:
# Platform packages at the end
cat >> release_notes.md << EOF

### 📦 Packages

The following platform packages have been updated to v$VERSION_NO_V:
- \`@seydx/node-av-darwin-arm64@$VERSION_NO_V\`
- \`@seydx/node-av-darwin-x64@$VERSION_NO_V\`
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@
path = externals/node-gyp
url = https://github.com/seydx/node-gyp.git
branch = main
[submodule "externals/binary-data"]
path = externals/binary-data
url = https://github.com/seydx/binary-data.git
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Native Node.js bindings for FFmpeg with full TypeScript support. Provides direct
- [Benchmarks](#benchmarks)
- [Sync vs Async Operations](#sync-vs-async-operations)
- [Memory Safety Considerations](#memory-safety-considerations)
- [Electron](#electron)
- [Examples](#examples)
- [Prebuilt Binaries](#prebuilt-binaries)
- [Troubleshooting](#troubleshooting)
Expand Down Expand Up @@ -460,6 +461,22 @@ The key difference: Async methods don't block the Node.js event loop, allowing o

NodeAV provides direct bindings to FFmpeg's C APIs, which work with raw memory pointers. The high-level API adds safety abstractions and automatic resource management, but incorrect usage can still cause crashes. Common issues include mismatched video dimensions, incompatible pixel formats, or improper frame buffer handling. The library validates parameters where possible, but can't guarantee complete memory safety without limiting functionality. When using the low-level API, pay attention to parameter consistency, resource cleanup, and format compatibility. Following the documented patterns helps avoid memory-related issues.

## Electron

NodeAV fully supports Electron applications. The prebuilt binaries are ABI-compatible with Electron, so no native rebuild is required during packaging. Both the native bindings and the bundled FFmpeg CLI binaries work seamlessly within Electron's main process.

Two complete examples are available: one using [Electron Forge](https://github.com/seydx/node-av/tree/main/examples/electron/forge) and one using [Electron Builder](https://github.com/seydx/node-av/tree/main/examples/electron/builder).

If you encounter module resolution errors like `Cannot find module 'lib/binary-stream'`, add this override to your project's `package.json`:

```json
{
"overrides": {
"@shinyoshiaki/binary-data": "npm:@seydx/binary-data@0.6.2"
}
}
```

## Examples

| Example | FFmpeg | Low-Level API | High-Level API |
Expand Down Expand Up @@ -519,7 +536,6 @@ NodeAV provides direct bindings to FFmpeg's C APIs, which work with raw memory p
| `transcode-aac` | [✓](https://github.com/FFmpeg/FFmpeg/tree/master/doc/examples/transcode_aac.c) | [✓](https://github.com/seydx/node-av/tree/main/examples/transcode-aac.ts) | |
| `transcode` | [✓](https://github.com/FFmpeg/FFmpeg/tree/master/doc/examples/transcode.c) | [✓](https://github.com/seydx/node-av/tree/main/examples/transcode.ts) | |


## Prebuilt Binaries

Prebuilt binaries are available for multiple platforms:
Expand Down
3 changes: 2 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default [
'**/.tmp/**',
'**/externals/**',
'**/examples/tests/**',
'**/examples/electron/**',
'**/projects/**',
'**/testdata/**',
'**/ffbuild/**',
Expand All @@ -47,7 +48,7 @@ export default [
}),
{
...jsdoc.configs['flat/recommended-typescript'],
files: ['src/ffmpeg/*.ts', 'src/lib/*.ts', 'src/api/*.ts', 'src/api/utilities/*.ts'],
files: ['src/ffmpeg/*.ts', 'src/lib/*.ts', 'src/api/*.ts', 'src/api/utilities/*.ts', 'src/utils/*.ts'],
rules: {
...jsdoc.configs['flat/recommended-typescript'].rules,
'jsdoc/tag-lines': [
Expand Down
9 changes: 9 additions & 0 deletions examples/electron/builder/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
6 changes: 6 additions & 0 deletions examples/electron/builder/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
dist
out
.DS_Store
.eslintcache
*.log*
6 changes: 6 additions & 0 deletions examples/electron/builder/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
out
dist
pnpm-lock.yaml
LICENSE.md
tsconfig.json
tsconfig.*.json
4 changes: 4 additions & 0 deletions examples/electron/builder/.prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
singleQuote: true
semi: false
printWidth: 100
trailingComma: none
12 changes: 12 additions & 0 deletions examples/electron/builder/build/entitlements.mac.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
<true/>
</dict>
</plist>
Binary file added examples/electron/builder/build/icon.icns
Binary file not shown.
Binary file added examples/electron/builder/build/icon.ico
Binary file not shown.
Binary file added examples/electron/builder/build/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions examples/electron/builder/electron-builder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
appId: com.nodeav.electron-builder-demo
productName: node-av Demo
directories:
buildResources: build
files:
- '!**/.vscode/*'
- '!src/*'
- '!electron.vite.config.{js,ts,mjs,cjs}'
- '!{.eslintcache,eslint.config.mjs,.prettierignore,.prettierrc.yaml,dev-app-update.yml,CHANGELOG.md,README.md}'
- '!{.env,.env.*,.npmrc,pnpm-lock.yaml}'
- '!{tsconfig.json,tsconfig.node.json,tsconfig.web.json}'
asarUnpack:
- resources/**
- node_modules/node-av/**
- node_modules/@seydx/**
win:
executableName: electron-app
nsis:
artifactName: ${name}-${version}-setup.${ext}
shortcutName: ${productName}
uninstallDisplayName: ${productName}
createDesktopShortcut: always
mac:
entitlementsInherit: build/entitlements.mac.plist
extendInfo:
- NSCameraUsageDescription: Application requests access to the device's camera.
- NSMicrophoneUsageDescription: Application requests access to the device's microphone.
- NSDocumentsFolderUsageDescription: Application requests access to the user's Documents folder.
- NSDownloadsFolderUsageDescription: Application requests access to the user's Downloads folder.
notarize: false
dmg:
artifactName: ${name}-${version}.${ext}
linux:
target:
- AppImage
- snap
- deb
maintainer: electronjs.org
category: Utility
appImage:
artifactName: ${name}-${version}.${ext}
npmRebuild: false
publish:
provider: generic
url: https://example.com/auto-updates
22 changes: 22 additions & 0 deletions examples/electron/builder/electron.vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { resolve } from 'path'
import { defineConfig } from 'electron-vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig({
main: {
build: {
rollupOptions: {
external: ['node-av']
}
}
},
preload: {},
renderer: {
resolve: {
alias: {
'@renderer': resolve('src/renderer/src')
}
},
plugins: [vue()]
}
})
40 changes: 40 additions & 0 deletions examples/electron/builder/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { defineConfig } from 'eslint/config'
import tseslint from '@electron-toolkit/eslint-config-ts'
import eslintConfigPrettier from '@electron-toolkit/eslint-config-prettier'
import eslintPluginVue from 'eslint-plugin-vue'
import vueParser from 'vue-eslint-parser'

export default defineConfig(
{ ignores: ['**/node_modules', '**/dist', '**/out'] },
tseslint.configs.recommended,
eslintPluginVue.configs['flat/recommended'],
{
files: ['**/*.vue'],
languageOptions: {
parser: vueParser,
parserOptions: {
ecmaFeatures: {
jsx: true
},
extraFileExtensions: ['.vue'],
parser: tseslint.parser
}
}
},
{
files: ['**/*.{ts,mts,tsx,vue}'],
rules: {
'vue/require-default-prop': 'off',
'vue/multi-word-component-names': 'off',
'vue/block-lang': [
'error',
{
script: {
lang: 'ts'
}
}
]
}
},
eslintConfigPrettier
)
Loading