Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS build #36

Closed
thomasza92 opened this issue Feb 5, 2024 · 60 comments
Closed

macOS build #36

thomasza92 opened this issue Feb 5, 2024 · 60 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@thomasza92
Copy link

Hi,

Great work. Was just wondering if it's possible to get this working on Apple Silicon? I tried to build from source (cargo build) with gstreamer installed via brew but was met with something like 700+ errors.

I wouldn't mind helping to test or patch either!

Thanks

@valadaptive
Copy link
Owner

If you're willing to help with making a macOS build, that'd be great! I haven't been able to do so myself because I don't have any Apple hardware.

What kinds of errors are you getting? Have you installed the gstreamer development headers as well or just the binaries?

@thomasza92
Copy link
Author

thomasza92 commented Feb 6, 2024

If you're willing to help with making a macOS build, that'd be great! I haven't been able to do so myself because I don't have any Apple hardware.

What kinds of errors are you getting? Have you installed the gstreamer development headers as well or just the binaries?

I have gstreamer and gstreamer-development installed using brew. Right now, the package simdnoise-3.1.6 is failing to compile. It looks like it's trying to compile as x86 instead of ARM.

There is an issue on the repo asking about Apple Silicon compatibility here: verpeteren/rust-simd-noise/issues/52 where it's mentioned that it should work if support for Apple Silicon is added to the simdeez project. An issue there, arduano/simdeez/issues/61 seems to indicate that support is already included.

I'll try to see if I can get these running on Apple Silicon and go from there. If you have any advice or suggestions I'm definitely able to follow them and report back with my results!

EDIT: Simdeez seems to compile fine by cloning the repository and building for apple silicon with cargo build --target aarch64-apple-darwin.

I was actually able to get ntsc-rs compiled and running on the latest version of Sonoma (MacBook Pro M1 Max) by removing the simdnoise-3.1.6 package and all references to it. There were quite a few, most located in ntsc.rs, which I am sure means it will not function properly now, however it shows that this dependency is the only one preventing cross compilation to Apple Silicon.

@RedMations
Copy link

What about Mac intel?

@valadaptive
Copy link
Owner

That simdnoise issue is annoying. It looks like the last version was published 3 years ago and the port to a version of simdeez which supports arm64 is a WIP still.

Even so, there's a scalar fallback that should work in the absense of a specific SIMD version for a given platform. I'm not sure why that's not being used; I'll try to investigate.

@thomasza92
Copy link
Author

That simdnoise issue is annoying. It looks like the last version was published 3 years ago and the port to a version of simdeez which supports arm64 is a WIP still.

Even so, there's a scalar fallback that should work in the absense of a specific SIMD version for a given platform. I'm not sure why that's not being used; I'll try to investigate.

Is there another library that could be used to generate noise, that is as fast as simdnoise, but regularly maintained & working cross platform? I realize this could require a lot of rewrite & benchmarking but maybe a separate branch to investigate this possibility would be worthwhile. I saw some comments in the ntsc-rs code that suggested that there were also some other quirks with this library as well..

I am not an expert at Rust by any means, and have an extremely limited knowledge on video processing, but I've forked ntsc-rs and can try to play around with this on my own time. A cursory search on Github shows a few other noise libraries written in Rust that may be suitable.

I'd also like to say thanks again for all the hard work, and for your willingness to work towards improving accessibility for the project. I would love to use this either standalone or as an OFX plugin on my MacBook Pro. I think if it was working it would be the best VHS emulation effect available on Apple Silicon. I have tried Maxon's Universe 'VHS' and it is not cheap and also does not look anything like VHS...

@thomasza92
Copy link
Author

Crazily enough I actually got it running now by using noise-rs in place of simdnoise and doing some hacky patching.

Something to note: the current version of gstreamer that is provided by brew at the moment is broken.. so I had to manually install gstreamer and add the following environment variables to .zshrc in order to compile successfully:

PKG_CONFIG_PATH="/Library/Frameworks/GStreamer.framework/Versions/1.0/lib/pkgconfig"

PATH="/Library/Frameworks/GStreamer.framework/Versions/1.0/bin:$PATH"

DYLD_FALLBACK_LIBRARY_PATH="/Library/Frameworks/GStreamer.framework/Versions/1.0/lib"

Building the project with cargo build --target aarch64-apple-darwin --release and running ntsc-rs-standalone seems to work great now. I'm able to real time preview a 1920x1080 video with all of the effects enabled.

Render time was 20 seconds for a 30 second 1920x1080 video with the following settings:
Quality: 50
Encoding Speed: 8
4:2:0 Chroma Subsampling: On

@valadaptive
Copy link
Owner

valadaptive commented Feb 8, 2024

I tried using FastNoiseLite but it was substantially slower--10.2ms/frame vs 6.8ms/frame on my built-in benchmark. You can see my code on the noise branch. I did a quick benchmark of your noise-rs version, and it takes 28.459ms/frame.

You can run the benchmark with RAYON_NUM_THREADS=1 cargo bench --bench filter_profile. Note that this will give slower results because multithreading is disabled for more consistent performance, but the numbers are consistent relative to each other and that's the important part.

@thomasza92
Copy link
Author

I tried using FastNoiseLite but it was substantially slower--10.2ms/frame vs 6.8ms/frame on my built-in benchmark. You can see my code on the noise branch. I did a quick benchmark of your noise-rs version, and it takes 28.459ms/frame.

You can run the benchmark with RAYON_NUM_THREADS=1 cargo bench --bench filter_profile. Note that this will give slower results because multithreading is disabled for more consistent performance, but the numbers are consistent relative to each other and that's the important part.

Good to know! I ran the benchmark myself just now and got 20ms~. You are right, it is substantially slower than simdnoise.

Relatively speaking, it is still plenty fast enough for my own use cases! For real world practical example, I was able to render out a 3m49s long 1920 x 1080 video @ 23.98 fps in one minute!

I had a feeling that this library would be slower, but until simdnoise is updated there exists no alternative for Apple Silicon users. In the meantime, I will keep fooling around with my fork and if someone checks the issues now they can at least run my much slower version!

Another thing to note is that the OpenFX version does not seem to be working either, which I will try to work on maybe at some point. I think it is because MacOS OFX plugins expect .plist files and some other stuff. I tried putting the bundle in my OFX folder but DaVinci Resolve did not like it and gave the very useful error message in log: Failed to load NtscRs.ofx.bundle

Thanks again!

@valadaptive
Copy link
Owner

I'm working on an simdnoise port that uses a different SIMD library that supports arm64 and properly falls back to scalar operations. I'll let you know when that's done.

@valadaptive
Copy link
Owner

Try pulling the latest main branch; I've updated it with my own fork of simdnoise. Let me know if it works, and how well the benchmarks run if so.

@valadaptive valadaptive added the bug Something isn't working label Feb 9, 2024
@thomasza92
Copy link
Author

Try pulling the latest main branch; I've updated it with my own fork of simdnoise. Let me know if it works, and how well the benchmarks run if so.

That was fast! It is compiling successfully now! The benchmark is reporting 10ms, twice as fast as my version using the noise-rs library. Great work!

However, there is a bug with the 'edge wave' feature now. When enabled, the preview screen goes black, and I am only able to see part of the screen with very low settings. It looks like it is creating black lines that go through the entire picture from edge to edge. Turning the frequency all the way up makes the black lines thinner, allowing me to see more of the image, but all of the other parameters have to be turned all the way to their lowest setting for me to see anything (besides for speed, which seems to be working correctly).

@valadaptive
Copy link
Owner

I missed some incorrect casts in the original code (they were float-to-int conversions but should've been float-to-int bitcasts) which seem to produce NaNs only on ARM. Try again with the latest main branch, and run the benchmark again--NaNs may have different performance characteristics.

@thomasza92
Copy link
Author

I missed some incorrect casts in the original code (they were float-to-int conversions but should've been float-to-int bitcasts) which seem to produce NaNs only on ARM. Try again with the latest main branch, and run the benchmark again--NaNs may have different performance characteristics.

It's working perfectly now! Thank you so much for the hard work! 😄 I will try to work on something at some point to give back to the project. Really! Please let me know if there is anything else I can do to help. Thanks again!

@valadaptive
Copy link
Owner

Since you have an ARM processor, can you try running the benchmark on the main branch then comparing it to the simd branch? I implemented a SIMD version of the IIR filter and it's faster on x86_64, but I don't have any ARM hardware to test with.

@thomasza92
Copy link
Author

Since you have an ARM processor, can you try running the benchmark on the main branch then comparing it to the simd branch? I implemented a SIMD version of the IIR filter and it's faster on x86_64, but I don't have any ARM hardware to test with.

Great work! On my end the simd branch is showing a significant performance increase compared to main.

main branch performance: 10.096 ms
simd branch performance: 5.57 ms

@sivercone
Copy link

hi, is there instruction how to run this on macos?

@valadaptive
Copy link
Owner

I haven't tried it myself, but these instructions should help. Essentially, you'll need to install GStreamer (use the development installer), add some variables to your .zshrc (use Command+Shift+. to show hidden files), clone this repository, and then cargo build --target aarch64-apple-darwin --release.

@thomasza92
Copy link
Author

thomasza92 commented Feb 19, 2024

It's also necessary to clone the openfx repo into ntsc-rs/crates/openfx-plugin/vendor so the third party vendor files are included, as compiling will not currently complete without openfx headers (at least on mac version)

edit: i've included full and thorough instructions on compiling for apple silicon below

@thomasza92
Copy link
Author

Apple Silicon Instructions

Before continuing, I feel it's necessary to mention that I am not using Apple's Clang compiler. If this is your first time compiling Rust or C/C++ projects from source, I would highly recommend installing LLVM to use instead of Apple's native Clang compiler that ships with Xcode. This will save you A LOT of headaches!! If you do not have LLVM or Rust installed yet I have included instructions on how to do this as well in order to be completely comprehensive.

Installing LLVM may not be necessary for compiling nstc-rs, but since this is the environment I compiled it in, I wanted to note this in these instructions.

LLVM & Rust

  1. Use Homebrew to install LLVM:
brew install llvm
  1. Add the following lines to .zshrc (this example is for v17.0.6_1, change the lines if the version has been updated)
export CC="/opt/homebrew/Cellar/llvm/17.0.6_1/bin/clang"
export CXX="/opt/homebrew/Cellar/llvm/17.0.6_1/bin/clang++"
export CFLAGS="-isysroot $(xcrun -show-sdk-path) ${CFLAGS}"
export CXXFLAGS="-isysroot $(xcrun -show-sdk-path) ${CXXFLAGS}"
export LDFLAGS="-L$(xcrun -show-sdk-path)/usr/lib ${LDFLAGS}"
export SDKROOT=$(xcrun -show-sdk-path)
export PATH="/opt/homebrew/Cellar/llvm/17.0.6_1/bin/${PATH:+:${PATH}
  1. Grab the latest version of Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup update
  1. Verify you have Rust & LLVM installed by running the following command in Terminal:
rustc --version && clang --version

which should return something similar to:

rustc 1.76.0 (07dca489a 2024-02-04)
Homebrew clang version 17.0.6
Target: arm64-apple-darwin23.2.0
Thread model: posix
InstalledDir: /opt/homebrew/Cellar/llvm/17.0.6_1/bin

If it does not return this, reload your Terminal or in your ~ directory run:

source .zshrc

then executing the commands should return the proper result..

Ok now onto the real reason you are here :)..

Compiling ntsc-rs

  1. Install the 1.22 development version of GStreamer (https://gstreamer.freedesktop.org/download/#macos)
    note: at some point the brew version may be fixed, but I was having issues with it

  2. Add the following lines to .zshrc:

PKG_CONFIG_PATH="/Library/Frameworks/GStreamer.framework/Versions/1.0/lib/pkgconfig"
PATH="/Library/Frameworks/GStreamer.framework/Versions/1.0/bin:$PATH"
DYLD_FALLBACK_LIBRARY_PATH="/Library/Frameworks/GStreamer.framework/Versions/1.0/lib"
  1. Clone the ntsc-rs repository:
git clone https://github.com/valadaptive/ntsc-rs.git
  1. Clone the openfx repo into the vendor folder:
cd ntsc-rs/crates/openfx-plugin/vendor
git clone https://github.com/AcademySoftwareFoundation/openfx
  1. Build ntsc-rs:
cd ../../../
cargo build --target aarch64-apple-darwin --release
  1. Navigate to ntsc-rs/target/aarch64-apple-darwin/release and run ntsc-rs-standalone!

Please let me know if there are any issues with these instructions!! I tried to be as thorough as possible, and I will be sure to update them if I missed anything!

Another thing that I think is worth noting from these instructions is how difficult / intimidating it could be for a beginner wishing to use ntsc-rs and needing to compile it from source in order to use it. I am not completely familiar with all the solutions that exist for releasing binaries across multiple different architectures but I believe it's possible to utilize Github Actions with something like cross.

Here is something I found that may be useful if this is even possible or anything that the developer is interested in.

Again big thanks to @valadaptive for all the hard work and willingness to get this working on Apple Silicon! Hope my instructions can be helpful to someone!

@dobkun
Copy link

dobkun commented Feb 20, 2024

how to compile on intel mac?

@valadaptive
Copy link
Owner

how to compile on intel mac?

I think the above instructions should work pretty much the same; just replace all instances of aarch64-apple-darwin with x86_64-apple-darwin.

Another thing that I think is worth noting from these instructions is how difficult / intimidating it could be for a beginner wishing to use ntsc-rs and needing to compile it from source in order to use it. I am not completely familiar with all the solutions that exist for releasing binaries across multiple different architectures but I believe it's possible to utilize Github Actions with something like cross.

I definitely want to get something like that set up in the future. There are a few hurdles to overcome:

  • I need Apple hardware in order to make sure all the builds actually run properly, and also to get the basic build pipeline functioning before I try to get it running on GH Actions. I've tried running macOS in QEMU but it's not stable.
  • I need to figure out how to compile not only the base ntsc-rs application but also the After Effects and OpenFX plugins. As you noted, OpenFX seems to require some sort of plist file. The After Effects plugin is even more complicated; IIRC it needs some ancient Xcode tools that are still shipped but have no documentation on how to use properly.
  • While it's possible to get standalone unsigned applications to run by going into System Preferences, dynamic libraries like the VFX plugins must be signed, which requires a $99/yr Apple developer license.

@valadaptive valadaptive added the help wanted Extra attention is needed label Mar 15, 2024
@valadaptive valadaptive pinned this issue Mar 15, 2024
@theofabilous
Copy link

I've been able to compile the standalone executable on apple silicon with homebrew's gstreamer using apple clang (not homebrew clang, it might work but I haven't tried it). No extra environment variable tinkering was necessary, all I did was clone the repo, ran brew install gstreamer, and built the ntsc-rs executable with cargo build -p gui --release. Hopefully this helps!

cargo version: cargo 1.76.0 (c84b36747 2024-01-18)
homebrew gstreamer version: 1.22.10
ntsc-rs version: 6cbb5c6 (head of main as of writing this)
macos version: Ventura 13.4.1 (22F82)
cpu: Apple M1 Max

output of clang --version:

Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: arm64-apple-darwin22.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

@Trevva1
Copy link

Trevva1 commented May 20, 2024

Apple Silicon Instructions

Thanks to everybody for their hard work on this! I had a question for @thomasza92
Also thanks for your detailed instructions for Mac and I think followed everything up until the end where it says "Navigate to ntsc-rs/target/aarch64-apple-darwin/release and run ntsc-rs-standalone"
Should there be a ntsc-rs-standalone file in that folder directory (an example of how it looks on my end https://imgur.com/m5ou0hC)

I also noticed this appears in my Terminal when I open it - /Users/trevva/.zshrc:12: unmatched "
Is there another step I'm missing?
I am new to this so apologies if I've missed something basic. TYIA

@valadaptive
Copy link
Owner

Yes, there should be an executable named ntsc-rs-standalone there. Are you getting any errors from cargo build?

@Trevva1
Copy link

Trevva1 commented May 21, 2024

Thanks for your quick response @valadaptive
I double checked over @thomasza92 Compiling notes above and I think the Step 5 (with the cargo build) is where I'm hitting a snag. When I run that in my Mac's terminal I get the error below:

trevva@Mac-Studio / % cargo build --target aarch64-apple-darwin --release
error: could not find `Cargo.toml` in `/` or any parent directory

I've also supplied an image below of my User directory incase the .zshrc, or other hidden files, are not in their correct place?
https://imgur.com/YZPcjiP

@valadaptive
Copy link
Owner

You need to be cd'd into the repository directory itself.

@Trevva1
Copy link

Trevva1 commented May 21, 2024

Thanks again @valadaptive and apologies for that basic mistake and I think this should be the command below?

cd /Users/trevva/ntsc-rs
cargo build --target aarch64-apple-darwin --release

However I am getting some errors in the build and maybe I'm still missing a simple fix?

Last login: Tue May 21 11:39:46 on ttys000
/Users/trevva/.zshrc:12: unmatched "
trevva@Mac-Studio ~ % cd /Users/trevva/ntsc-rs
trevva@Mac-Studio ntsc-rs % cargo build --target aarch64-apple-darwin --release
   Compiling glib-sys v0.18.1
   Compiling gobject-sys v0.18.0
   Compiling gstreamer-sys v0.21.2
   Compiling gio-sys v0.18.1
   Compiling objc2-encode v2.0.0-pre.2
   Compiling futures-executor v0.3.30
   Compiling parking_lot v0.12.1
   Compiling objc_id v0.1.1
   Compiling futures-channel v0.3.30
   Compiling gstreamer-base-sys v0.21.1
   Compiling simdeez v2.0.0-dev3
   Compiling emath v0.27.0
   Compiling ecolor v0.27.0
   Compiling num-integer v0.1.46
   Compiling unicode-bidi v0.3.15
   Compiling base64 v0.21.7
   Compiling percent-encoding v2.3.1
   Compiling cursor-icon v1.1.0
   Compiling smol_str v0.2.1
   Compiling prettyplease v0.2.16
   Compiling nohash-hasher v0.2.0
   Compiling parking v2.2.0
   Compiling rustix v0.38.31
The following warnings were emitted during compilation:

warning: [email protected]: 

error: failed to run custom build command for `glib-sys v0.18.1`

Caused by:
  process didn't exit successfully: `/Users/trevva/ntsc-rs/target/release/build/glib-sys-0f1ef944fcd0bd30/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=GLIB_2.0_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:warning=
  pkg-config exited with status code 1
  > PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 pkg-config --libs --cflags glib-2.0 glib-2.0 >= 2.56

  The system library `glib-2.0` required by crate `glib-sys` was not found.
  The file `glib-2.0.pc` needs to be installed and the PKG_CONFIG_PATH environment variable must contain its parent directory.
  The PKG_CONFIG_PATH environment variable is not set.

  HINT: if you have installed the library, try setting PKG_CONFIG_PATH to the directory containing `glib-2.0.pc`.

warning: build failed, waiting for other jobs to finish...
The following warnings were emitted during compilation:

warning: [email protected]: 

error: failed to run custom build command for `gobject-sys v0.18.0`

Caused by:
  process didn't exit successfully: `/Users/trevva/ntsc-rs/target/release/build/gobject-sys-4f4ea8efdc67262c/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=GOBJECT_2.0_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:warning=
  pkg-config exited with status code 1
  > PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 pkg-config --libs --cflags gobject-2.0 gobject-2.0 >= 2.56

  The system library `gobject-2.0` required by crate `gobject-sys` was not found.
  The file `gobject-2.0.pc` needs to be installed and the PKG_CONFIG_PATH environment variable must contain its parent directory.
  The PKG_CONFIG_PATH environment variable is not set.

  HINT: if you have installed the library, try setting PKG_CONFIG_PATH to the directory containing `gobject-2.0.pc`.

The following warnings were emitted during compilation:

warning: [email protected]: 

error: failed to run custom build command for `gstreamer-sys v0.21.2`

Caused by:
  process didn't exit successfully: `/Users/trevva/ntsc-rs/target/release/build/gstreamer-sys-a89bda172224df3d/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=GSTREAMER_1.0_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:warning=
  pkg-config exited with status code 1
  > PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 pkg-config --libs --cflags gstreamer-1.0 gstreamer-1.0 >= 1.14

  The system library `gstreamer-1.0` required by crate `gstreamer-sys` was not found.
  The file `gstreamer-1.0.pc` needs to be installed and the PKG_CONFIG_PATH environment variable must contain its parent directory.
  The PKG_CONFIG_PATH environment variable is not set.

  HINT: if you have installed the library, try setting PKG_CONFIG_PATH to the directory containing `gstreamer-1.0.pc`.

The following warnings were emitted during compilation:

warning: [email protected]: 

error: failed to run custom build command for `gio-sys v0.18.1`

Caused by:
  process didn't exit successfully: `/Users/trevva/ntsc-rs/target/release/build/gio-sys-fe98c5616fd1d160/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=GIO_2.0_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:warning=
  pkg-config exited with status code 1
  > PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 pkg-config --libs --cflags gio-2.0 gio-2.0 >= 2.56

  The system library `gio-2.0` required by crate `gio-sys` was not found.
  The file `gio-2.0.pc` needs to be installed and the PKG_CONFIG_PATH environment variable must contain its parent directory.
  The PKG_CONFIG_PATH environment variable is not set.

  HINT: if you have installed the library, try setting PKG_CONFIG_PATH to the directory containing `gio-2.0.pc`.

trevva@Mac-Studio ntsc-rs % 

@Trevva1
Copy link

Trevva1 commented May 22, 2024

Thanks for those suggestions, but I'm still getting errors.

  • I ran the echo $PKG_CONFIG_PATH in Terminal, but nothing happened
  • The Gstreamer packages have been installed
  • It looks like everything is there for the pkg-config - https://imgur.com/adjBrij

The other thing that might be causing issues is that when I open Terminal there is already a note for the last line in .zshrc. Not sure if that is causing issues and if it needs to be resolved?

Last login: Wed May 22 13:40:11 on ttys000
/Users/trevva/.zshrc:12: unmatched "
trevva@Mac-Studio

@Trevva1
Copy link

Trevva1 commented May 22, 2024

@valadaptive I appreciate your time on this and don't want to take up any more of your time until I've had a thorough look over everything.
Next week when I have time I'll double check over my set up/files and my mac system (as there may be conficts)

@mobile-bungalow
Copy link

So I haven't read through this entire chain as it's rather long but I would like to point people in the direction of the new and improved rust AE bindings, This fork contains build scripts that I have gotten to work on both Windows and MacOs. It uses Lipo to build universal binaries so you only need one MacOs distributable, and it completely handles compiling the PiPl for you. It also contains scripts for writing the plugin bundle and signing it with a development cert! The maintainer has graciously translated tons of examples from adobe, it might be worth a look.

@thomasza92
Copy link
Author

thomasza92 commented Jun 25, 2024

@valadaptive I appreciate your time on this and don't want to take up any more of your time until I've had a thorough look over everything.

Next week when I have time I'll double check over my set up/files and my mac system (as there may be conficts)

Sorry for my absence! I hope you were able to get this to work! It looks like according to @theofabilous it should be possible to compile with apple clang and no extra steps to compile so I would definitely go for that route instead 😁 there are some silly mistakes in my instructions that should prolly be updated anyway (like not pointing to a specific version of llvm or any brew installed software in .zshrc since every time you update it will break the links). Let me know if you still need any help.

So I haven't read through this entire chain as it's rather long but I would like to point people in the direction of the new and improved rust AE bindings, This fork contains build scripts that I have gotten to work on both Windows and MacOs. It uses Lipo to build universal binaries so you only need one MacOs distributable, and it completely handles compiling the PiPl for you. It also contains scripts for writing the plugin bundle and signing it with a development cert! The maintainer has graciously translated tons of examples from adobe, it might be worth a look.

I have a development cert and wouldn't mind signing for this if there was an efficient way to produce binaries for Apple Silicon + AE + OFX, especially since it sounds like AE might be easier to implement now but that still leaves automated building and OFX up in the air. I was particularly interested in using as an OFX plugin myself but when I looked into it before it seemed like it would be a lot of trouble to get it to work with Apple Silicon.

@valadaptive
Copy link
Owner

valadaptive commented Jun 25, 2024

Hi! Good to hear from you.

In the past couple months, I purchased a Mac Mini and got the standalone application and OpenFX plugin building on macOS--see the macos branch for that work. They're universal binaries so they should work cross-architecture.

All that remains is:

  • Building the AE plugin. I have the actual plugin binary building, but haven't figured out the metadata and bundle stuff yet, and I don't have a macOS version of AE to test my work on.
  • Signing the app and plugins. My real name unfortunately must be present in the final artifacts because of Apple's developer program, and I have some legal stuff to take care of first.

I might look into the Rust bindings for AE a bit more in the future--I checked them out a bit ago but was worried the build process might be too inflexible (e.g. I might run into an obscure error within their build process and have no way to fix it).

If you could test out the After Effects plugin for me once I have it building, that would be greatly appreciated!

@thomasza92
Copy link
Author

thomasza92 commented Jun 25, 2024

Sounds great! Hope you are enjoying the Mac Mini! Once I have a moment I'll be sure to checkout the new branch and give the OFX plugin a test run 😄. I also have no problem testing the AE plugin in the future or any other testing you may need done just let me know! Cheers!

@valadaptive
Copy link
Owner

valadaptive commented Jul 1, 2024

Hey @thomasza92! I've rewritten the AE plugin in Rust, and I'm hoping you can test it out for me. If you want to test out my other build scripts while you're at it, that would be appreciated (hopefully it should be straightforward).

There are some Cargo "scripts" on the macos branch (really just Rust programs) for building the application and plugins:

cargo xtask macos-bundle --release # for the standalone application
cargo xtask build-ofx-plugin --macos-universal --release # for the OpenFX plugin
cargo xtask macos-ae-plugin --macos-universal --release # for the After Effects plugin.

The OpenFX plugin will be under crates/openfx-plugin/build, and the others will be under the top-level build folder.

They're not signed yet; you should be able to sign them using something like this snippet (the plugin path should be build/ntsc-rs.plugin).

Thanks so much for helping out with this process!

@winterwarrior3
Copy link

Howdy! Been following this. I am a Resolve user, would love to text OpenFX Mac version if you need momre testers. Tried to build using the above instructions but was getting errors.

@valadaptive
Copy link
Owner

valadaptive commented Jul 2, 2024

Howdy! Been following this. I am a Resolve user, would love to text OpenFX Mac version if you need momre testers. Tried to build using the above instructions but was getting errors.

I've added updated macOS build instructions in the documentation. Try following those and let me know if it works (and provide the error messages if it doesn't).

@valadaptive
Copy link
Owner

I've produced a build of ntsc-rs for macOS that runs on my computer (standalone, OpenFX, and After Effects/Premiere). However, I'm not sure if it works on anyone else's computer, both because there is no code signing and because I haven't tested it on Apple Silicon.

If you'd like to help me test it out, here's the latest build. Let me know:

  • For the standalone app:
    • Does it run when you double-click it (with a "this was downloaded from the internet" warning), or does it refuse to run until you manually allow it to in the Privacy & Security settings?
    • Does it start up properly? Give it a few minutes to get past the loading screen.
    • Can you load a variety of image and video formats without errors? If you do run into any errors, screenshot them and post them here.
  • For the OpenFX plugin:
    • Does it run in DaVinci Resolve downloaded from Blackmagic?
    • Does it run in DaVinci Resolve from the App Store? (I believe Blackmagic says that the App Store version won't load unsigned plugins.)
  • For the After Effects/Premiere plugin:
    • Does it load (appear in the plugin list) and run properly in After Effects?
    • Does it load (appear in the plugin list) and run properly in Premiere?

I'd like to fill out the full matrix of platforms:

Intel Apple Silicon (ARM)
Standalone
OpenFX
After Effects
Premiere Pro

@larsjaakko
Copy link

Hello! I randomly stumbled on this thread, quickly tried to run the AE plugin on my M2 macbook pro. Got the error complaining about lack of code signing.
Screenshot by Dropbox Capture

Might try to build it myself tomorrow, given time, I'll report back in that case.

@valadaptive
Copy link
Owner

@larsjaakko The plugin doesn't "run" per se--are you getting this error when you try to open the .plugin file, or when you open After Effects? You need to install it to /Library/Application Support/Adobe/Common/Plug-ins/7.0/MediaCore.

Does it show up in the Stylize category of the effects pane if you do so?

@larsjaakko
Copy link

@valadaptive Apologies for the vague description — it was installed in the appropriate plugin folder, but the above dialogue pops up immediately on starting After Effects. After clicking it away a few times I was able to open a project and try applying it — so it does indeed appear in the effects pane. Trying to run it does trigger the same dialogue, however, in addition to a few AE specific ones complaining about not being able to run the plugin file.

@winterwarrior3
Copy link

Reporting in:

The MacOS Standalone seems to be working just fine after some testing. It does prompt an error at first startup due to it not being signed by a developer but that can be bypassed by right clicking on the application and clicking "open". You are then given the opportunity to open regardless of the signature or lackthereof.

The OpenFX bundle is not being recognized by Resolve so I am unable to test it.

@valadaptive
Copy link
Owner

@larsjaakko If you go into the Privacy & Security settings (in System Settings), is there an option to allow the plugin to run (via the Open Anyway button)? You may need to get the dialog to appear again--apparently the option only shows up for about an hour afterwards.

@winterwarrior3 Ditto with Resolve--do you get a "cannot be opened" dialog when you open Resolve? You may need to re-enable the plugin under the "Video Plug-ins" settings page to get the dialog to appear, and once more after allowing it to run in System Settings. It may also be related to whether you installed the App Store version of Resolve or not.

I'm trying to figure out the best way to release this before I can get a developer certificate--for bureaucratic reasons, it may take a while.

@winterwarrior3
Copy link

winterwarrior3 commented Jul 11, 2024 via email

@valadaptive
Copy link
Owner

valadaptive commented Jul 11, 2024

What does it take to get a developers certificate?

$99/yr, plus your legal name on all the software you publish under it.

@winterwarrior3
Copy link

winterwarrior3 commented Jul 11, 2024 via email

@valadaptive
Copy link
Owner

My username [at] protonmail dot com

@larsjaakko
Copy link

larsjaakko commented Jul 12, 2024

@valadaptive Success! It worked perfectly, and so far works fine in testing with various videos.

EDIT: getting some sudden crashes on a somewhat complex composition, no crash logs. Will revert to using the standalone to pre-process the videos for now — let me know if there's anything I can provide in terms of debugging.

@winterwarrior3
Copy link

@valadaptive — Emailed you. Also, after removing the bundle and then re-adding it— I was able to get MacOS to prompt me to "Open Anyway" in Privacy & Settings. It works like a charm now after a restart in Resolve. No issues yet!

@valadaptive
Copy link
Owner

@larsjaakko Try installing the debug version of the plugin--let me know if it gives any error messages before crashing:
ntsc-rs_debug.plugin.zip

If you could provide a reduced test case .aep for me to reproduce the issue, that'd be great as well. How often does it crash, and is there any discernable pattern to it?

@valadaptive
Copy link
Owner

@larsjaakko Have you had a chance to test out the debug version of the plugin? I want to get the After Effects plugin fixed up before making a new release.

@valadaptive
Copy link
Owner

I think I found the issue with the After Effects plugin. If anyone was having trouble, try installing the latest version and let me know if it improves things.

@larsjaakko
Copy link

@valadaptive Apologies for the radio silence! I've been in the middle of moving countries, so notifications took a back seat.

Just installed the new version, and no crashes to report in about 2 hours of work or so. Previous version crashed several times within a few minutes. Looking very good so far!

@mobile-bungalow
Copy link

mobile-bungalow commented Jul 25, 2024

Works over here too! 🚢

@valadaptive
Copy link
Owner

I've released official macOS packages in v0.8.0. Running the installers will require some fiddling with Gatekeeper, but once installed, they should work fine with video editing software.

I'm closing this issue since macOS builds have been released now, but let me know if you run into any issues with them.

@valadaptive valadaptive unpinned this issue Jul 29, 2024
@dobkun
Copy link

dobkun commented Sep 30, 2024

Hello! I randomly stumbled on this thread, quickly tried to run the AE plugin on my M2 macbook pro. Got the error complaining about lack of code signing.

go to Settings -> Security & Privacy -> click on the lock -> allow the plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

10 participants