OBS Mac M1/ARM compile progress - Scripting

Heino Falcke

New Member
Following some recipes on Reddit (e.g., https://www.reddit.com/r/obs/comments/njwbxl/compiling_obs_for_apple_silicon_m1/) I have been able to compile OBS natively on the new Mac M1 ARM processor. I need to do this, because the Rosetta emulation comes with a significant performance penalty and for what I need to do (several sources in our church and some special previews) I can’t even stream with 25 FPS/HD with Rosetta (but can do this when using the ARM/M1 code).

I was able to compile ndi-obs and the Advanced Scene Switcher and they both work (which is really nice!). I also run Lua-Scripts. That also compiles with the latest luajit beta, however, when running even a simple script (eg. a countdown timer) OBS crashes after 1-2 mins (just counting down). I am afraid this has to do with an issue in Luajit (pcall??), but wonder whether anyone has been able to get OBS Lua scripting working natively on an M1?
 

Attachments

  • crashlog.txt
    11.4 KB · Views: 65
There are multiple ways to build for Apple Silicon.
Please try them out.

 

Heino Falcke

New Member
Interesting to hear that countdown timer works for you (I assume this is a .lua script?). It doesn't work for me on two different computers.

In any case, thank you, for this useful list. I actually used the one from Ben Mitchell in your list. Which of the versions did you use? Did you have to do anything special to include lua scripting? (I had to).

There are multiple ways to build for Apple Silicon.
Please try them out.

 

Heino Falcke

New Member
Sorry, just now watched the video clip. So, indeed this is an M1 compile with a .lua script (so disregard my question in brackets above). Mine crashed after 1:50 secs, your's didn't. So, that still leaves the question which of these compile recipes did you use ? (and which brew targets did you use - luajit doesn't compile via homebrew)?

Interesting to hear that countdown timer works for you (I assume this is a .lua script?). It doesn't work for me on two different computers.

In any case, thank you, for this useful list. I actually used the one from Ben Mitchell in your list. Which of the versions did you use? Did you have to do anything special to include lua scripting? (I had to).
 
Sorry, just now watched the video clip. So, indeed this is an M1 compile with a .lua script (so disregard my question in brackets above). Mine crashed after 1:50 secs, your's didn't. So, that still leaves the question which of these compile recipes did you use ? (and which brew targets did you use - luajit doesn't compile via homebrew)?
Hmm, I don't remember, but I think it was one of the following methods.
 

neonyme

New Member
Is there any way that I could get the Advanced Scene Switcher compiled for M1/ARM? I spent quite a lot of time to have a setup of OBS and plugins that is now well up-n-running on my M1 iMac, so I'm not willing to rebuild/reinstall anything at this time... but this is the plugin i'm missing the most. It would be wonderful if I could get my hand on a package just for this plugin! :) Thanks!
 
Is there any way that I could get the Advanced Scene Switcher compiled for M1/ARM? I spent quite a lot of time to have a setup of OBS and plugins that is now well up-n-running on my M1 iMac, so I'm not willing to rebuild/reinstall anything at this time... but this is the plugin i'm missing the most. It would be wonderful if I could get my hand on a package just for this plugin! :) Thanks!
from https://github.com/WarmUpTill/SceneSwitcher

compiled here. not tested.
download password bnmihfsi
 

Heino Falcke

New Member
It was quite straightforward to compile the advanced scene switcher "in tree". I cloned the GIT rep of the advanced scene switcher into obs-studio/UI/frontend-plugins/

cd obs-studio/UI/frontend-plugins/
git clone --recursive https://github.com/WarmUpTill/SceneSwitcher.git

and edited CMakeLists.txt to include
add_subdirectory(SceneSwitcher)

BTW, I also added obs-ndi
add_subdirectory(obs-ndi)

or compile directly
cd obs-studio/UI/frontend-plugins/
git clone --recursive https://github.com/Palakis/obs-ndi.git
cd obs-ndi
mkdir build && cd build
cmake -DLIBOBS_INCLUDE_DIR="/Users/falcke/Git/obs-studio/libobs"
-DLIBOBS_LIB="/Users/falcke/Git/obs-studio/libobs/libobs.dylib"
-DOBS_FRONTEND_LIB="/Users/falcke/Git/obs-studio/build/UI/obs-frontend-api/libobs-frontend-api.dylib"
-DQt5Core_DIR=/opt/homebrew/Cellar/qt\@5/5.15.2/lib/cmake/Qt5Core/
-DQt5Widgets_DIR=/opt/homebrew/Cellar/qt\@5/5.15.2/lib/cmake/Qt5Widgets/
..

BTW - you just to make sure you have the correct libndi.4.dylib for ARM and copy it to /usr/local/lib/

Is there any way that I could get the Advanced Scene Switcher compiled for M1/ARM? I spent quite a lot of time to have a setup of OBS and plugins that is now well up-n-running on my M1 iMac, so I'm not willing to rebuild/reinstall anything at this time... but this is the plugin i'm missing the most. It would be wonderful if I could get my hand on a package just for this plugin! :) Thanks!
 

Heino Falcke

New Member
Strange. It sill doesn't work for me. Can't read method 2 well, but it doesn't seem to do anything special for LUA scripting (but i see Python mentioned), and method 1 doesn't automatically include obslua if you hadn't installed it already yourself. (I had it and also tried Method 1, so OBS compiled with lua, but then crashed already when loading a script). Could it be that you had an older version of luajit installed already?

Hmm, I don't remember, but I think it was one of the following methods.
 
Last edited:
Strange. It sill doesn't work for me. Can't read method 2 well, but it doesn't seem to do anything special for LUA scripting (but i see Python mentioned), and method 1 doesn't automatically include obslua if you hadn't installed it already yourself. (I had it and also tried Method 1, so OBS compiled with lua, but then crashed already when loading a script). Could it be that you had an older version of luajit installed already?

I'm sorry. I don't know why it crashes in your environment.

I recorded a video of me building OBS for your reference.
 

hakihaki95

New Member
I am building new version. and Lua script works well.
I used this script https://www.kilinbox.net/2021/02/obsarmbuild.html
and changed new cef binary address.
new binary code has no cefBrowserSettings.web_security = STATE_DISABLED;
I could solve this problem with https://qiita.com/kitazaki/items/2484a5475bbe89426c06
open "plugins/obs-browser/obs-browser-source.cpp"
and find "cefBrowserSettings.web_security = STATE_DISABLED;"
remove this line or add "//" in front of this line.
That's all.
I upload my script. and Copy it to CI folder.
and run.
 

Attachments

  • full-build-macos-arm64.sh.zip
    7 KB · Views: 76

shiggitay

Member
There are multiple ways to build for Apple Silicon.
Please try them out.


When I try and run that script I get this error:


/tmp/obs/plugins/obs-outputs/librtmp/handshake.h:29:10: fatal error: 'mbedtls/arc4.h' file not found
#include <mbedtls/arc4.h>
^~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [plugins/obs-outputs/CMakeFiles/obs-outputs.dir/librtmp/rtmp.c.o] Error 1
make[1]: *** [plugins/obs-outputs/CMakeFiles/obs-outputs.dir/all] Error 2
make: *** [all] Error 2
[Fri Aug 20 20:14:28 EDT 2021] FATAL: Unable to build OBS; see above logs for more info. Try running this instead: REPACKAGE=true ./install.sh

Can anyone help with that? Or can someone post a binary?
 
Last edited:

hakihaki95

New Member
I am building new version. and Lua script works well.
I used this script https://www.kilinbox.net/2021/02/obsarmbuild.html
and changed new cef binary address.
new binary code has no cefBrowserSettings.web_security = STATE_DISABLED;
I could solve this problem with https://qiita.com/kitazaki/items/2484a5475bbe89426c06
open "plugins/obs-browser/obs-browser-source.cpp"
and find "cefBrowserSettings.web_security = STATE_DISABLED;"
remove this line or add "//" in front of this line.
That's all.
I upload my script. and Copy it to CI folder.
and run.
you need to run
./full-build-mac-arm64.sh -p -b
And, you can find new compiled one in "build" folder. app and dmg. Both are the same thing.
When I try and run that script I get this error:


/tmp/obs/plugins/obs-outputs/librtmp/handshake.h:29:10: fatal error: 'mbedtls/arc4.h' file not found
#include <mbedtls/arc4.h>
^~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [plugins/obs-outputs/CMakeFiles/obs-outputs.dir/librtmp/rtmp.c.o] Error 1
make[1]: *** [plugins/obs-outputs/CMakeFiles/obs-outputs.dir/all] Error 2
make: *** [all] Error 2
[Fri Aug 20 20:14:28 EDT 2021] FATAL: Unable to build OBS; see above logs for more info. Try running this instead: REPACKAGE=true ./install.sh

Can anyone help with that? Or can someone post a binary?
There is some problem with newest mbedlts.
use this.
 

shiggitay

Member
you need to run
./full-build-mac-arm64.sh -p -b
And, you can find new compiled one in "build" folder. app and dmg. Both are the same thing.

There is some problem with newest mbedlts.
use this.

I used that fork and I'm still getting that same error. I don't have ./full-build-mac-arm64.sh -p -b. Can't you just post a binary you were able to compile?
 

shiggitay

Member
you need to run
./full-build-mac-arm64.sh -p -b
And, you can find new compiled one in "build" folder. app and dmg. Both are the same thing.

There is some problem with newest mbedlts.
use this.

EDIT: I actually went to that Japanese site and I c/p'd all the command line stuff and I got it building, but it fails at the last step:


[100%] Built target obs
[OBS-Studio] Creating macOS app bundle
[OBS-Studio] Preparing OBS.app bundle
+ Copy binary and plugins...
mv: rename ./OBS.app/Contents/Resources/data/obs-scripting/_obspython.so to ./OBS.app/Contents/MacOS/_obspython.so: No such file or directory
+ ERROR during build step: bundle app

No matter what I do I can't even launch the resulting OBS.app that's generated in the build directory. Help? Are you on the OBS Discord? Here's an invite link just in case you're not there already: https://discord.gg/obsproject.
 
Last edited:

Heino Falcke

New Member
You can simply comment out all lines in full-build-macos-arm64.sh that contain obspython

# ./OBS.app/Contents/MacOS/_obspython.so

# /bin/mv ./OBS.app/Contents/Resources/data/obs-scripting/_obspython.so ./OBS.app/Contents/MacOS/
# /bin/mv ./OBS.app/Contents/Resources/data/obs-scripting/obspython.py ./OBS.app/Contents/MacOS/
 

Heino Falcke

New Member
To add the advanced scene switcher:
add line ./OBS.app/Contents/PlugIns/advanced-scene-switcher.so
to BUNDLE_PLUGINS=(
in full-build-macos-arm64.sh

in the Git clone of obs-studio download the source code of the advanced scene switcher:
cd obs-studio/UI/frontend-plugins/
git clone --recursive https://github.com/WarmUpTill/SceneSwitcher.git

Then modify the obs-studio/UI/frontend-plugins/CMakeLists.txt file and add an entry for the scene switcher:
add_subdirectory(SceneSwitcher)

finally rerun the build script full-build-macos-arm64.sh
 

Heino Falcke

New Member
Finally, I was able to compile a version of OBS running natively on M1, that includes lua scripting, the Advanced Scence Switcher, and obs-ndi. I used the script by hakihaki95 and slightly modified it to avoid the error with python. I have attached the script and the notes/commands I used to compile the whole thing. This could probably be turned into a complete script by someone.
 

Attachments

  • OBS-ARM-M1-compile instructions.zip
    8.6 KB · Views: 349
Top