Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Streampunk/beamcoder
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: descriptinc/beamcoder
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.

Commits on Nov 10, 2021

  1. Merge pull request #8 from Streampunk/master

    Merge in latest beamcoder v0.6.15 GPL-3.0-or-later
    cvanwinkle authored Nov 10, 2021
    Copy the full SHA
    ffb4b56 View commit details

Commits on May 30, 2023

  1. Prebuild (#1)

    * experimental prebuild
    
    * skip preinstall, install native deps on linux
    
    * npm run lint
    
    * run install_ffmpeg, prebuild differently?
    
    * try to fix mac (update homebrew) and windows builds (gh token)
    
    * maybe fix macos build, add electron builds
    
    * update deps, files list, install script
    
    * update package version
    
    * include dll files in build, remove electron ones (doesn't seem like we need them with napi)
    
    * try to get build working on windows, cleanup github action script
    
    * try another approach to prebuilding
    
    * copy mac libraries in
    
    * try caret escape
    
    * let's go windows
    
    * come onnnnn
    
    * if this doesn't work…
    
    * update copy_mac_libs to recurse
    
    * change logging in copy_mac_libs
    
    * do not try to rebuild with prebuild version
    
    * set -id in copy_mac_libs
    
    * better log output in copy_mac_libs
    
    * disable copy_mac_libs to test
    
    * use loader_path instead of rpath (to search for library relative to the .node file)
    
    * fix stream.metadata type definition
    
    * try arm64 build
    
    * 0.6.10-rc.8
    
    * Use custom shared libraries from ffmpeg-build-scripts fork instead of homebrew (#2)
    
    * use custom shared libraries from ffmpeg-build-scripts fork instead of homebrew
    
    * add ffmpegPath and ffprobePath on main module
    
    * include dirs
    
    * skip arm64 build
    
    * rc10
    
    * handle symlinks when unzipping
    
    * Update package.json
    
    * skip prebuild install when trying to build the prebuilds :-)
    
    * Update package.json
    
    * Update package.json
    
    * Update package.json
    
    * patch-package is dev dep
    
    * dev patch-packages
    
    * paths entry point
    
    * path types
    
    * Update package.json
    
    * fixes
    
    * version bump
    
    * don't patch-package for normal install
    
    * Update package.json
    
    * console error if --enable-small
    
    * try to include ffmpeg/ffprobe from ffmpeg-ffprobe-static for linux/windows builds
    
    * try regex again
    
    * windows escaping
    
    courtesy of https://octopus.com/blog/powershell-pipe-escaping
    
    * bash??
    
    * rc4 -- should have a better way to update that
    
    * Update package.json
    
    * cleanup
    
    * Update paths.js
    
    * Update paths.d.ts
    
    * Update package.json
    
    * Update .github/workflows/prebuild.yml
    
    Co-authored-by: Marcello Bastéa-Forte <marcello@descript.com>
    
    * Update .github/workflows/prebuild.yml
    
    Co-authored-by: Marcello Bastéa-Forte <marcello@descript.com>
    
    * PR feedback
    
    * Create .node-version
    
    Co-authored-by: Marcello Bastéa-Forte <marcello@descript.com>
    
    * Attempt to fix types for paths
    
    * ...
    
    * treat warnings as errors
    
    * fix config error
    
    * bump version number
    
    * do not add .exe to beamcoder.node on windows
    
    * bump versions (#5)
    
    * ffmpeg-ffprobe-static update (#6)
    
    * Update to latest ffmpeg-ffprobe-static
    
    * use ubuntu 18.04 (ffmpeg ppa not available for 20.04)
    
    * Cvanwink/arm 3 (#9)
    
    * Fix definition for metadata property
    
    * Remove unneeded import
    
    * Stop input and output links sorting by name
    
    * Ensure decoder is created from codec_id if available
    
    * v0.6.11
    
    * build with debug symbols (temporary)
    
    * chore: upgrade dependencies to FFmpeg 4.4 - fixes broken build
    
    * chore: version bump for publish
    
    * Improved handling of FFmpeg minor version changes
    
    * Remove redundant setter leading to channel layout warning message
    
    * Bump path-parse from 1.0.6 to 1.0.7
    
    Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7.
    - [Release notes](https://github.com/jbgutierrez/path-parse/releases)
    - [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7)
    
    ---
    updated-dependencies:
    - dependency-name: path-parse
      dependency-type: indirect
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    * Add support for hardware accelerated decoding
    
    * Fix zero size frame, update version
    
    * Update CircleCI test image
    
    * Update cache tag
    
    * Build info for CircleCI test image
    
    * Simplify decoder hwaccel flag
    
    * better stab at versioning
    
    * bump version
    
    * one more version
    
    * hack for missing definitions in latest ffmpeg?
    
    * Download proper build of ffmpeg from our repo for arm64
    
    * Add arm64 paths for building beamcoder
    
    * update node version to run as a native arm64 process when building beamcoder
    
    https://descript-inc.slack.com/archives/C01G891V16Z/p1637013049098700
    
    * fix const vs let usage
    
    * Bump package version to pick up new arm64 build of ffmpeg
    
    * Fix getting ffmpeg build on x86_64 vs x64
    
    * Add new package-lock
    
    * Build release for both x86_64 and arm64
    
    * Build beamcoder based off of target_arch and not host_arch
    
    * Try to get both ffmpeg versions downloaded on macOS
    
    * Try to clean build directory in-between x64 and arm64
    
    * Try verbose output to see why CI can't build arm64
    
    * fix position of --verbose flag
    
    * bump node version to 17.0.1 so it can maybe cross-compile
    
    * Try CI node version 16.13.0 since that matches what is on the GitHub OS image
    
    * Don't clean build directory
    
    * Fix node packaging for x64 on macOS
    
    * Update to latest FFmpeg build
    
    * Fix version string to not have extra 'v'
    
    * Update Beamcoder to 1.33rc3
    
    * v0.6.10-rc.41
    
    * Update Windows ffmpeg to 4.4
    
    * v0.6.10-rc.42
    
    * Revert "Update Windows ffmpeg to 4.4"
    
    This reverts commit 1073fb2.
    
    * fix bad merge
    
    * Fix another merge error
    
    * Fix ffmpeg extraction on windows
    
    * add verbose tag for windows
    
    * try prebuild on windows without bash
    
    * v0.6.15-rc.2
    
    * Revert "try prebuild on windows without bash"
    
    This reverts commit d5784ae.
    
    * try git-bash instead of bash
    
    * try specific bash
    
    * quote the temp path
    
    * no quote and no escape for temp path
    
    * go back to using bash on windows
    
    * temporarily comment out ffprobe which doesn't seem to be available
    
    * restore ffmpeg copies
    
    * Fix regex on windows
    
    * v0.6.15-rc.3
    
    * 0.6.15-rc.4
    
    * Try using FFmpeg shared instead of static on Windows
    
    * Revert "Try using FFmpeg shared instead of static on Windows"
    
    This reverts commit 721001f.
    
    * Update ffmpeg-ffprobe-static to 4.4.0-rc.11
    
    * v0.6.15-rc.6
    
    * #85 Add arm64 to supported linux platforms
    
    * add linux arm64 prebuild
    
    ---------
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: Simon Rogers <scriptorian@streampunk.media>
    Co-authored-by: Steve Rubin <nerdforlife@gmail.com>
    Co-authored-by: Richard Cartwright <spark@streampunk.media>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: Simon Rogers <scriptorian@users.noreply.github.com>
    
    * update package lock
    
    * Update package-lock.json
    
    * try including libzimg and checking deps
    
    * Update prebuild.yml
    
    * Update install_ffmpeg.js
    
    * Update install_ffmpeg.js
    
    * force latest node-gyp to fix incompat between python 3.11 and node-gyp 6
    
    * try statically linking libstdc++
    
    * Update package.json
    
    * Update binding.gyp
    
    * Update package.json
    
    * build on ubuntu 20
    
    * i don't think these were doing anything
    
    ---------
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: Steve Rubin <nerdforlife@gmail.com>
    Co-authored-by: Charles Van Winkle <1332142+cvanwinkle@users.noreply.github.com>
    Co-authored-by: Simon Rogers <scriptorian@streampunk.media>
    Co-authored-by: Richard Cartwright <spark@streampunk.media>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: Simon Rogers <scriptorian@users.noreply.github.com>
    7 people authored May 30, 2023
    Copy the full SHA
    06b843d View commit details

Commits on Dec 13, 2023

  1. Merge remote-tracking branch 'upstream/master' into sk/merge-upstream

    # Conflicts:
    #	binding.gyp
    #	package-lock.json
    #	package.json
    srikanth-descript committed Dec 13, 2023
    Copy the full SHA
    d305886 View commit details
  2. Fixup after merge

    srikanth-descript committed Dec 13, 2023
    Copy the full SHA
    acfff75 View commit details
  3. Copy the full SHA
    ad017b5 View commit details

Commits on Dec 14, 2023

  1. Copy the full SHA
    a0182f8 View commit details
  2. Adding git

    srikanth-descript committed Dec 14, 2023
    Copy the full SHA
    943c4d7 View commit details
  3. Adding git-lfs

    srikanth-descript committed Dec 14, 2023
    Copy the full SHA
    1360c96 View commit details
  4. Copy the full SHA
    401651a View commit details
  5. Copy the full SHA
    5b69096 View commit details
  6. Copy the full SHA
    54150ba View commit details
  7. Adding bashrc

    srikanth-descript committed Dec 14, 2023
    Copy the full SHA
    d117d0c View commit details
  8. Really?

    srikanth-descript committed Dec 14, 2023
    Copy the full SHA
    a25fdaf View commit details
  9. Copy the full SHA
    e9cf877 View commit details
  10. Copy the full SHA
    1f6ae3b View commit details
  11. Adding setuptools

    srikanth-descript committed Dec 14, 2023
    Copy the full SHA
    3e076ba View commit details
  12. updating node-gyp

    srikanth-descript committed Dec 14, 2023
    Copy the full SHA
    6d496da View commit details
  13. Copy the full SHA
    b5fc432 View commit details
  14. Copy the full SHA
    6f645d3 View commit details
  15. WCGW?

    srikanth-descript committed Dec 14, 2023
    Copy the full SHA
    3d570f8 View commit details
  16. Creating release

    srikanth-descript committed Dec 14, 2023
    Copy the full SHA
    d9e152d View commit details
  17. Adding versions

    srikanth-descript committed Dec 14, 2023
    Copy the full SHA
    3a213e0 View commit details
  18. Copy the full SHA
    9615339 View commit details
  19. Copy the full SHA
    7897126 View commit details
  20. Adding version.

    srikanth-descript committed Dec 14, 2023
    Copy the full SHA
    8bdeefa View commit details
  21. Set node user

    srikanth-descript committed Dec 14, 2023
    Copy the full SHA
    beef236 View commit details

Commits on Dec 15, 2023

  1. Copy the full SHA
    3ce8bda View commit details
  2. Copy the full SHA
    aacb47f View commit details
  3. Copy the full SHA
    39115d6 View commit details
  4. updating tags

    srikanth-descript committed Dec 15, 2023
    Copy the full SHA
    9607b47 View commit details
  5. Fixing build tag

    srikanth-descript committed Dec 15, 2023
    Copy the full SHA
    ddbc0c5 View commit details

Commits on Dec 20, 2023

  1. Copy the full SHA
    344815b View commit details

Commits on Dec 21, 2023

  1. Adding log

    srikanth-descript committed Dec 21, 2023
    Copy the full SHA
    5971f6b View commit details
  2. Copy the full SHA
    9dfc562 View commit details

Commits on Jan 3, 2024

  1. Copy the full SHA
    dd37776 View commit details
  2. Copy the full SHA
    75bb34a View commit details

Commits on Jul 8, 2024

  1. Updating pre-install script

    Srikanth Kotagiri committed Jul 8, 2024
    Copy the full SHA
    0ec8a28 View commit details
  2. Adding support for shared build from descripinc/ffmpeg-build-script f…

    …or lix
    Srikanth Kotagiri committed Jul 8, 2024
    Copy the full SHA
    02e3274 View commit details
  3. GIT

    Srikanth Kotagiri committed Jul 8, 2024
    Copy the full SHA
    5d8046a View commit details
  4. GITLFS

    Srikanth Kotagiri committed Jul 8, 2024
    Copy the full SHA
    e4c7c59 View commit details
  5. Adding write permissions to uplaod artifacts

    Srikanth Kotagiri committed Jul 8, 2024
    Copy the full SHA
    5f888e1 View commit details
  6. Fixing indentation

    Srikanth Kotagiri committed Jul 8, 2024
    Copy the full SHA
    91a6bbb View commit details
  7. indent

    Srikanth Kotagiri committed Jul 8, 2024
    Copy the full SHA
    e7e3ed6 View commit details
  8. Split windows and macos jobs

    Srikanth Kotagiri committed Jul 8, 2024
    Copy the full SHA
    1bf57f2 View commit details

Commits on Jul 11, 2024

  1. Working linux prebuild

    Srikanth Kotagiri committed Jul 11, 2024
    Copy the full SHA
    041b73e View commit details
  2. Copy the full SHA
    070f655 View commit details

Commits on Jul 16, 2024

  1. New beamcoder prebuild release with ffmpeg 6

    Srikanth Kotagiri committed Jul 16, 2024
    Copy the full SHA
    4257cfd View commit details

Commits on Jul 22, 2024

  1. Copy the full SHA
    ed71d82 View commit details

Commits on Jul 24, 2024

  1. Copy the full SHA
    b27dc79 View commit details
  2. Copy the full SHA
    07e75cc View commit details
Showing with 8,441 additions and 1,073 deletions.
  1. +100 −0 .github/workflows/prebuild.yml
  2. +3 −0 .gitignore
  3. +1 −0 .node-version
  4. +1 −1 README.md
  5. +81 −31 binding.gyp
  6. +6 −0 index.js
  7. +5 −0 install.js
  8. +49 −28 install_ffmpeg.js
  9. +8,047 −1,004 package-lock.json
  10. +34 −7 package.json
  11. +43 −0 patches/prebuild+12.1.0.patch
  12. +3 −0 paths.d.ts
  13. +53 −0 paths.js
  14. +5 −0 postinstall.js
  15. +8 −0 src/codec.cc
  16. +2 −2 types/Filter.d.ts
100 changes: 100 additions & 0 deletions .github/workflows/prebuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: prebuild
on: [push]

permissions:
contents: write

jobs:
linux-package:
permissions:
contents: write
runs-on: ubuntu-24.04
container:
image: node:18.20.4-bookworm
steps:
- name: check Linux dependencies
shell: bash
run: |
apt update
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --no-install-suggests -y \
git git-lfs libxcb1 unzip curl python3-setuptools build-essential libxcb1-dev \
libavcodec-dev libavformat-dev libavdevice-dev libavfilter-dev libavutil-dev \
libpostproc-dev libswresample-dev libswscale-dev libzimg-dev
- uses: actions/checkout@v2
with:
lfs: true

- name: npm install
run: npm install
env:
PREBUILD: true

- name: check Linux dependencies
run: node ./install_ffmpeg.js

- name: prebuild for Linux (x64)
run: npx prebuild --runtime napi --arch x64 --include-regex '(\.node|\.dylib|ffmpeg|ffprobe)$' --upload ${{ secrets.GITHUB_TOKEN }}

windows-package:
permissions:
contents: write
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
lfs: true
- name: Use nodejs
uses: actions/setup-node@v1
with:
node-version: 16.13.0

- name: npm install
run: npm install
env:
PREBUILD: true

- name: install Windows dependencies
run: node ./install_ffmpeg.js

- name: prebuild for Windows
run: npx prebuild --runtime napi --include-regex '.node|.dll|.exe' --verbose --upload ${{ secrets.GITHUB_TOKEN }}
shell: bash

macos-package:
permissions:
contents: write
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
with:
lfs: true

- name: Use nodejs
uses: actions/setup-node@v1
with:
node-version: 16.13.0

- name: install Mac build dependencies (brew)
run: |
brew install nasm pkg-config python-packaging python-setuptools
- name: npm install
run: npm install
env:
PREBUILD: true

- name: install Mac dependencies (shared release x64)
run: node ./install_ffmpeg.js --arch x64

- name: install Mac dependencies (shared release arm64)
run: node ./install_ffmpeg.js --arch arm64

- name: prebuild Release for macOS (x64)
run: npx prebuild --runtime napi --arch x64 --include-regex '(\.node|\.dylib|ffmpeg|ffprobe)$' --verbose --upload ${{ secrets.GITHUB_TOKEN }}

- name: clean build directory for cross-compiling
run: rm ./build/Release/*.dylib || true

- name: prebuild Release for macOS (arm64)
run: npx prebuild --runtime napi --arch arm64 --include-regex '(\.node|\.dylib|ffmpeg|ffprobe)$' --verbose --upload ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -62,6 +62,7 @@ typings/

# Native module build dir
build/
prebuilds/

# FFmpeg install folder
ffmpeg/
@@ -73,3 +74,5 @@ ffmpeg/
# Editors and IDE's
*.swp
.vscode/

.DS_Store
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16.20.2
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -105,7 +105,7 @@ On Linux, use the appropriate package manager to install the FFmpeg 4.1 developm
sudo add-apt-repository ppa:jonathonf/ffmpeg-4
sudo add-apt-repository ppa:savoury1/ffmpeg5
sudo apt-get update
sudo apt-get install libavcodec-dev libavformat-dev libavdevice-dev libavfilter-dev libavutil-dev libpostproc-dev libswresample-dev libswscale-dev
sudo apt-get install libavcodec-dev libavformat-dev libavdevice-dev libavfilter-dev libavutil-dev libpostproc-dev libswresample-dev libswscale-dev libzimg-dev

An example for Debian / Redhat / Fedora / CentOs will follow.

112 changes: 81 additions & 31 deletions binding.gyp
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
{
"targets": [{
"target_name" : "beamcoder",
"sources" : [ "src/beamcoder.cc", "src/beamcoder_util.cc",
"defines": [
"NAPI_VERSION=<(napi_build_version)"
],
"sources" : [ "src/beamcoder.cc", "src/beamcoder_util.cc",
"src/log.cc" ,
"src/governor.cc", "src/demux.cc",
"src/decode.cc", "src/filter.cc",
"src/encode.cc", "src/mux.cc",
"src/packet.cc", "src/frame.cc",
"src/codec_par.cc", "src/format.cc",
"src/codec.cc", "src/hwcontext.cc"],
"src/codec.cc", "src/hwcontext.cc" ],
"conditions": [
['OS!="win"', {
['OS=="linux"', {
"variables": {
"ffmpeg_version": "1.49.rc.1",
"target_arch_override": "<!(node -p \"'<(target_arch)' === 'x64' ? 'x86_64' : '<(target_arch)'\")",
},
"defines": [
"__STDC_CONSTANT_MACROS"
],
@@ -21,28 +28,89 @@
"cflags_cc": [
"-std=c++11",
"-fexceptions"
]
],
"include_dirs": [
"<(module_root_dir)/ffmpeg/ffmpeg-ffprobe-shared-linux-<(target_arch_override).<(ffmpeg_version)/include/"
],

"link_settings": {
"ldflags": [
"--verbose"
],
"libraries": [
"-Wl,-rpath,./build/Release/ "
"-L<(module_root_dir)/ffmpeg/ffmpeg-ffprobe-shared-linux-<(target_arch_override).<(ffmpeg_version)/ "
"-lavcodec",
"-lavdevice",
"-lavfilter",
"-lavformat",
"-lavutil",
"-lpostproc",
"-lswresample",
"-lswscale",
"-lzimg"
]
},
"copies": [
{
"destination": "<(PRODUCT_DIR)",
"files": [
"node_modules/ffmpeg-ffprobe-static/ffmpeg",
"node_modules/ffmpeg-ffprobe-static/ffprobe",
]
}
]
}],
['OS!="win" and OS!="linux"', {
["OS=='mac'", {
"variables": {
"ffmpeg_version": "1.49.rc.1",
"target_arch_override": "<!(node -p \"'<(target_arch)' === 'x64' ? 'x86_64' : '<(target_arch)'\")",
},
"defines": [
"__STDC_CONSTANT_MACROS"
],
"include_dirs": [
"<(module_root_dir)/ffmpeg/ffmpeg-ffprobe-shared-darwin-<(target_arch_override).<(ffmpeg_version)/include/"
],
"link_settings": {
"library_dirs": [
"<(module_root_dir)/ffmpeg/ffmpeg-ffprobe-shared-darwin-<(target_arch_override).<(ffmpeg_version)/"
],
"libraries": [
"-Wl,-rpath,@loader_path",
"-lavcodec",
"-lavdevice",
"-lavfilter",
"-lavformat",
"-lavutil",
"-lpostproc",
"-lswresample",
"-lswscale"
"-lswscale",
"-lzimg"
],
},
'xcode_settings': {
'MACOSX_DEPLOYMENT_TARGET': '10.11',
'OTHER_CFLAGS': ['-fno-rtti', '-fno-exceptions', '-arch <(target_arch_override)', '-v'],
'OTHER_LDFLAGS': ['-arch <(target_arch_override)'],
},
"copies": [
{
"destination": "<(PRODUCT_DIR)",
"files": [
"<!@(node -p \"require('fs').readdirSync('ffmpeg/ffmpeg-ffprobe-shared-darwin-<(target_arch_override).<(ffmpeg_version)').map(f => 'ffmpeg/ffmpeg-ffprobe-shared-darwin-<(target_arch_override).<(ffmpeg_version)/' + f).join(' ')\")"
]
}
]
}
}],
}
],
['OS=="win"', {
"configurations": {
"Release": {
"msvs_settings": {
"VCCLCompilerTool": {
"RuntimeTypeInfo": "true"
"RuntimeTypeInfo": "true",
"AdditionalOptions": []
}
}
}
@@ -62,7 +130,7 @@
],
"copies": [
{
"destination": "build/Release/",
"destination": "<(PRODUCT_DIR)",
"files": [
"ffmpeg/ffmpeg-5.x-win64-shared/bin/avcodec-59.dll",
"ffmpeg/ffmpeg-5.x-win64-shared/bin/avdevice-59.dll",
@@ -71,31 +139,13 @@
"ffmpeg/ffmpeg-5.x-win64-shared/bin/avutil-57.dll",
"ffmpeg/ffmpeg-5.x-win64-shared/bin/postproc-56.dll",
"ffmpeg/ffmpeg-5.x-win64-shared/bin/swresample-4.dll",
"ffmpeg/ffmpeg-5.x-win64-shared/bin/swscale-6.dll"
"ffmpeg/ffmpeg-5.x-win64-shared/bin/swscale-6.dll",
"node_modules/ffmpeg-ffprobe-static/ffmpeg.exe",
"node_modules/ffmpeg-ffprobe-static/ffprobe.exe"
]
}
]
}],
['OS=="linux"', {
"libraries": [
"<!(pkg-config --libs libavcodec)",
"<!(pkg-config --libs libavdevice)",
"<!(pkg-config --libs libavfilter)",
"<!(pkg-config --libs libavformat)",
"<!(pkg-config --libs libavutil)",
"<!(pkg-config --libs libpostproc)",
"<!(pkg-config --libs libswresample)",
"<!(pkg-config --libs libswscale)"
]
}],
['OS=="mac"', {
"include_dirs" : [
"/opt/homebrew/Cellar/ffmpeg/5.0/include"
],
"library_dirs": [
"/opt/homebrew/Cellar/ffmpeg/5.0/lib",
]
}],
]
}]
}
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -35,6 +35,12 @@ https://github.com/Streampunk/beamcoder/blob/master/LICENSE`;
console.log(splash);
console.log('Using FFmpeg version', beamcoder.avVersionInfo());

if (Object.values(beamcoder.configurations()).some(value => value.includes('--enable-small'))) {
console.error('beamcoder will crash because ffmpeg is compiled' +
' with --enable-small (because, for example, codec->long_name is ' +
'NULL and beamcoder expects it to be defined)');
}

beamcoder.demuxerStream = beamstreams.demuxerStream;
beamcoder.muxerStream = beamstreams.muxerStream;

5 changes: 5 additions & 0 deletions install.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const {execSync} = require('child_process');

if (!process.env.PREBUILD) {
execSync('npx prebuild-install --target 4 --runtime napi');
}
77 changes: 49 additions & 28 deletions install_ffmpeg.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ const fs = require('fs');
const util = require('util');
const https = require('https');
const cp = require('child_process');
const { argv } = require('process');
const [ mkdir, access, rename, execFile, exec ] = // eslint-disable-line
[ fs.mkdir, fs.access, fs.rename, cp.execFile, cp.exec ].map(util.promisify);

@@ -83,7 +84,7 @@ async function inflate(rs, folder, name) {
return new Promise((comp, err) => {
console.log(`Unzipping '${folder}/${name}.zip'.`);
rs.pipe(unzip.Extract({ path: folder }).on('close', () => {
fs.rename(`./${folder}/${directoryName}`, `./${folder}/${name}`, () => {
fs.rename(`${folder}/${directoryName}`, `${folder}/${name}`, () => {
console.log(`Unzipping of '${folder}/${name}.zip' completed.`);
comp();
});
@@ -166,46 +167,66 @@ async function linux() {
console.error('libswscale.so.6 is not installed.');
result = 1;
}
if (stdout.indexOf('libzimg.so.2') < 0) {
console.error('libzimg.so.2 is not installed.');
result = 1;
}

if (result === 1) {
console.log(`Try running the following (Ubuntu/Debian):
sudo add-apt-repository ppa:jonathonf/ffmpeg-4
sudo apt-get install libavcodec-dev libavformat-dev libavdevice-dev libavfilter-dev libavutil-dev libpostproc-dev libswresample-dev libswscale-dev`);
sudo apt-get install libavcodec-dev libavformat-dev libavdevice-dev libavfilter-dev libavutil-dev libpostproc-dev libswresample-dev libswscale-dev libzimg-dev`);
process.exit(1);
}
return result;
}

async function darwin() {
console.log('Checking for FFmpeg dependencies via HomeBrew.');
let output;
let returnMessage;
console.log('Checking/downloading ffmpeg shared libraries');

await mkdir('ffmpeg').catch(e => {
if (e.code === 'EEXIST') return;
else throw e;
});

const version = '1.49.rc.1';

// default to platform-architecture
let arch = os.arch();

// but if the '--arch' argument is provided
// use the next argument as the value (e.g. 'x64' or 'arm64')
const overrideArchIndex = process.argv.indexOf('--arch');
if (0 < overrideArchIndex && overrideArchIndex < process.argv.length - 1) {
arch = process.argv[overrideArchIndex + 1];
}

try {
output = await exec('brew list ffmpeg');
returnMessage = 'FFmpeg already present via Homebrew.';
} catch (err) {
if (err.stderr !== 'Error: No such keg: /usr/local/Cellar/ffmpeg\n') {
console.error(err);
console.log('Either Homebrew is not installed or something else is wrong.\nExiting');
process.exit(1);
}

console.log('FFmpeg not installed. Attempting to install via Homebrew.');
try {
output = await exec('brew install nasm pkg-config texi2html ffmpeg');
returnMessage = 'FFmpeg installed via Homebrew.';
} catch (err) {
console.log('Failed to install ffmpeg:\n');
console.error(err);
process.exit(1);
}
if (arch === 'x64') {
arch = 'x86_64';
}

console.log(output.stdout);
console.log(returnMessage);
const ffmpegFilename = `ffmpeg-ffprobe-shared-darwin-${arch}.${version}`;
const tag = `v${version}`;

await access(`ffmpeg/${ffmpegFilename}`, fs.constants.R_OK).catch(async () => {
const ws = fs.createWriteStream(`ffmpeg/${ffmpegFilename}.zip`);
const url = `https://github.com/descriptinc/ffmpeg-build-script/releases/download/${tag}/${ffmpegFilename}.zip`
console.log(url);
await get(
ws,
url,
`${ffmpegFilename}.zip`
).catch(async (err) => {
if (err.name === 'RedirectError') {
const redirectURL = err.message;
await get(ws, redirectURL, `${ffmpegFilename}.zip`);
} else {
console.error(err);
throw err;
}
});

return 0;
await exec(`unzip ffmpeg/${ffmpegFilename}.zip -d ffmpeg/${ffmpegFilename}/`);
});
}

switch (os.platform()) {
9,051 changes: 8,047 additions & 1,004 deletions package-lock.json

Large diffs are not rendered by default.

41 changes: 34 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,38 @@
{
"name": "beamcoder",
"version": "0.7.1",
"name": "beamcoder-prebuild",
"version": "0.7.1-rc.18",
"description": "Node.js native bindings to FFmpeg.",
"main": "index.js",
"types": "index.d.ts",
"scripts": {
"preinstall": "node install_ffmpeg.js",
"install": "node-gyp rebuild",
"install": "node install.js",
"postinstall": "node postinstall.js",
"test": "tape test/*.js",
"lint": "eslint **/*.js",
"lint-html": "eslint **/*.js -f html -o ./reports/lint-results.html",
"lint-fix": "eslint --fix **/*.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Streampunk/beamcoder.git"
"url": "git+https://github.com/descriptinc/beamcoder.git"
},
"binary": {
"napi_versions": [
4
]
},
"files": [
"types/**",
"beamstreams.js",
"index.d.ts",
"index.js",
"paths.js",
"paths.d.ts",
"install.js",
"postinstall.js",
"LICENSE",
"README.md"
],
"keywords": [
"FFmpeg",
"libav",
@@ -30,16 +47,26 @@
"author": "Streampunk Media Ltd",
"license": "GPL-3.0-or-later",
"bugs": {
"url": "https://github.com/Streampunk/beamcoder/issues"
"url": "https://github.com/descriptinc/beamcoder/issues"
},
"homepage": "https://github.com/Streampunk/beamcoder#readme",
"homepage": "https://github.com/descriptinc/beamcoder#readme",
"dependencies": {
"bindings": "^1.5.0",
"prebuild-install": "^6.0.0",
"segfault-handler": "^1.3.0"
},
"devDependencies": {
"eslint": "^8.9.0",
"node-gyp": "^9.4.1",
"patch-package": "^6.2.2",
"prebuild": "^12.1.0",
"ffmpeg-ffprobe-static": "^5.1.0-rc.1",
"tape": "^5.5.2"
},
"overrides": {
"prebuild": {
"node-gyp": "^9.4.1"
}
},
"gypfile": true
}
43 changes: 43 additions & 0 deletions patches/prebuild+12.1.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
diff --git a/node_modules/prebuild/pack.js b/node_modules/prebuild/pack.js
index 7552a4d..3be8aae 100644
--- a/node_modules/prebuild/pack.js
+++ b/node_modules/prebuild/pack.js
@@ -20,20 +20,30 @@ function pack (filenames, tarPath, cb) {
tarStream.pipe(zlib.createGzip({ level: 9 })).pipe(ws)

eachSeries(filenames, function processFile (filename, nextFile) {
- fs.stat(filename, function (err, st) {
+ fs.lstat(filename, function (err, st) {
if (err) return nextFile(err)

- var stream = tarStream.entry({
+ var header = {
name: filename.replace(/\\/g, '/').replace(/:/g, '_'),
size: st.size,
mode: st.mode | mode('444') | mode('222'),
gid: st.gid,
- uid: st.uid
- })
-
- fs.createReadStream(filename).pipe(stream).on('finish', nextFile)
-
- stream.on('error', nextFile)
+ uid: st.uid,
+ }
+
+ if (st.isSymbolicLink()) {
+ fs.readlink(filename, function (err, linkname) {
+ if (err) return nextFile(err)
+ header.type = 'symlink'
+ header.linkname = linkname
+ tarStream.entry(header)
+ nextFile()
+ })
+ } else {
+ var stream = tarStream.entry(header)
+ fs.createReadStream(filename).pipe(stream).on('finish', nextFile)
+ stream.on('error', nextFile)
+ }
})
}, function allFilesProcessed (err) {
tarStream.finalize()
3 changes: 3 additions & 0 deletions paths.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const ffmpegPath: string | null;
export const ffprobePath: string | null;
export const beamcoderPath: string | null;
53 changes: 53 additions & 0 deletions paths.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
Aerostat Beam Coder - Node.js native bindings to FFmpeg
Copyright (C) 2019 Streampunk Media Ltd.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
https://www.streampunk.media/ mailto:furnace@streampunk.media
14 Ormiscaig, Aultbea, Achnasheen, IV22 2JJ U.K.
*/

const path = require('path');
const os = require('os');

function getPath(name, addDotExeOnWindows) {
const binaries = {
darwin: ['x64', 'arm64'],
linux: ['x64'],
win32: ['x64'],
};

const platform = process.env.npm_config_platform || os.platform();

const arch = process.env.npm_config_arch || os.arch();

if (!binaries[platform] || binaries[platform].indexOf(arch) === -1) {
return null;
}

return path.join(
__dirname,
'build',
// FIXME: toggleable
'Release',
platform === 'win32' && addDotExeOnWindows ? name + '.exe' : name
);
}

module.exports = {
ffmpegPath: getPath('ffmpeg', true),
ffprobePath: getPath('ffprobe', true),
beamcoderPath: getPath('beamcoder.node', false),
};
5 changes: 5 additions & 0 deletions postinstall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const {execSync} = require('child_process');

if (process.env.PREBUILD) {
execSync('npx patch-package');
}
8 changes: 8 additions & 0 deletions src/codec.cc
Original file line number Diff line number Diff line change
@@ -22,6 +22,14 @@
#include "codec.h"
#include "hwcontext.h"

#ifndef FF_DEBUG_VIS_QP
#define FF_DEBUG_VIS_QP 0x2000
#endif

#ifndef FF_DEBUG_VIS_MB_TYPE
#define FF_DEBUG_VIS_MB_TYPE 0x4000
#endif

napi_value getCodecCtxCodecID(napi_env env, napi_callback_info info) {
napi_status status;
napi_value result;
4 changes: 2 additions & 2 deletions types/Filter.d.ts
Original file line number Diff line number Diff line change
@@ -265,8 +265,8 @@ export interface VideoInputParam extends InputParam {
height: number
pixelFormat: string
pixelAspect: Array<number>
hw_device_ctx: HWDeviceContext // Optional
swPixelFormat: string // Optional
hw_device_ctx?: HWDeviceContext // Optional
swPixelFormat?: string // Optional
}
/** The required parameters for setting up audio filter inputs */
export interface AudioInputParam extends InputParam {