valadaptive / ntsc-rs

Free, open-source analog TV + VHS effect. Standalone application + plugin (After Effects, Premiere, and OpenFX).
Other
241 stars 4 forks source link

macOS build #36

Open thomasza92 opened 4 months ago

thomasza92 commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

What about Mac intel?

valadaptive commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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.

thomasza92 commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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

valadaptive commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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

2) 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}

3) Grab the latest version of Rust

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup update

4) 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"

3) Clone the ntsc-rs repository:

git clone https://github.com/valadaptive/ntsc-rs.git

4) Clone the openfx repo into the vendor folder:

cd ntsc-rs/crates/openfx-plugin/vendor
git clone https://github.com/AcademySoftwareFoundation/openfx

5) Build ntsc-rs:

cd ../../../
cargo build --target aarch64-apple-darwin --release

6) 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 commented 4 months ago

how to compile on intel mac?

valadaptive commented 4 months ago

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:

theofabilous commented 3 months ago

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 commented 1 month ago

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 commented 1 month ago

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

Trevva1 commented 1 month ago

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 commented 1 month ago

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

Trevva1 commented 1 month ago

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: glib-sys@0.18.1: 

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: gobject-sys@0.18.0: 

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: gstreamer-sys@0.21.2: 

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: gio-sys@0.18.1: 

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 % 
valadaptive commented 1 month ago

Re-read the instructions closelier and make sure you're following the part about .zshrc.

Trevva1 commented 1 month ago

Hey @valadaptive I've checked and re-applied all of the commands to the .zshrc file as below:

# Add Homebrew's executable directory to the front of the PATH
export PATH=/opt/local/bin:$PATH
export CC="/opt/homebrew/Cellar/llvm/18.1.5/bin/clang"
export CXX="/opt/homebrew/Cellar/llvm/18.1.5/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/18.1.5/bin/${PATH:+:${PATH}
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"

When I run a build in the terminal it's still showing gobject-sys@0.18.0/gstreamer-sys@0.21.2/gio-sys@0.18.1 failed to run custom build command for gobject-sys v0.18.0/gstreamer-video-sys v0.21.2 errors

However, it is creating a libntscrs.rlib file in the target/aarch64-apple-darwin/release folder

Do you have any other suggestions?

valadaptive commented 1 month ago

Is it the same error as above, including "The PKG_CONFIG_PATH environment variable is not set."?

Trevva1 commented 1 month ago

Yes I'm still getting the same errors - apologies for my inexperience and I'll try and do the best I can!

I saw the HINT that appeared in the Terminal and I tried to mess around with the .zshrc file (line 10) below PKG_CONFIG_PATH="/Library/Frameworks/GStreamer.framework/Versions/1.0/lib/pkgconfig" I reduced the line and changed it to PKG_CONFIG_PATH="/Library/Frameworks/GStreamer.framework"

New files were created in the /target/aarch64-apple-darwin/release folder The new files were libopenfx_plugin.dylib libntscrs_c_api.a libntscrs.rlib build-plugin I'm not sure if that is helpful at all?

valadaptive commented 1 month ago

PKG_CONFIG_PATH="/Library/Frameworks/GStreamer.framework/Versions/1.0/lib/pkgconfig" is what I have in my .zshrc and it builds fine for me.

Try the following:

Trevva1 commented 1 month ago

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

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 commented 1 month ago

@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 commented 1 week ago

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 commented 1 week ago

@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 commented 1 week ago

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:

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 commented 1 week ago

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 commented 1 day ago

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 commented 1 day ago

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 commented 23 hours ago

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).