Stremio/stremio-shell

Add Apple Silicon Support

Opened this issue ยท 14 comments

kokroo commented

https://www.reddit.com/r/Stremio/comments/15gijoq/stremio_for_apple_silicon_m1_m2_etc/

@_pajarito was able to compile Stremio for Apple Silicon, and I think we can do the same. One thing to note here is that it will save a lot of battery life, but we should also make sure that hardware video decoding is enabled. That will be the biggest battery life saver.

zisra commented

yes it's really laggy on my m2 laptop

kokroo commented

yes it's really laggy on my m2 laptop

It's laggy and also consumes too much battery. HDR content plays but the HDR effect is not present. I'm not complaining though, it's open source and free, this is just a humble request to the project developers.

What do you mean by laggy? I had M1 macbook pro for almost 3 years now and there is nothing 'laggy' it plays 4k content without issues. Be sure to enable hw accelerated decoding in the settings.

kokroo commented

What do you mean by laggy? I had M1 macbook pro for almost 3 years now and there is nothing 'laggy' it plays 4k content without issues. Be sure to enable hw accelerated decoding in the settings.

I have the M1 Pro and it does lag sometimes. Hardware acceleration is on but it's not really supported on macOS including HDR. That toggle doesn't change anything, try for yourself. And this application is a battery hog, no doubt.

zisra commented

What do you mean by laggy? I had M1 macbook pro for almost 3 years now and there is nothing 'laggy' it plays 4k content without issues. Be sure to enable hw accelerated decoding in the settings.

I can drop a recording some other time, but pressing every button has significant delay and animations are choppy

Seems like the main issue preventing a build for arm64 is libmpv, which wouldn't be an issue if Stremio wasn't using 6 year old binaries of it. As said in #326, switching to meson would make it significantly easier to manage cross-platform builds.

I thought this had to be a joke. 4 years Apple Silicon has been available. Even MS is going full-steam ahead with ARM on Windows now.

+1 for Apple silicon please. Normal version takes up a lot of CPU/Memory usage and is not battery efficient + it lags sometimes. It is usable but not a very good exp.

zavan commented

Instructions to build from source for Apple Silicon (requires git, homebrew and Xcode CLI Tools):

  1. Install and link the dependencies:
brew install mpv ffmpeg node cmake qt@5 openssl
brew install --cask qt-creator
brew link openssl --force
brew link qt5 --force
  1. Clone the repo and enter the directory:
git clone --recursive https://github.com/Stremio/stremio-shell.git
cd stremio-shell
  1. Make the following changes to ./CMakeLists.txt and ./mac/finalize.sh:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 047d5c0..5849ac2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -44,10 +44,10 @@ endif()
 if(APPLE)
   list(APPEND SOURCES images/stremio.icns)
   set_source_files_properties(images/stremio.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
-  set(MPV_LIBRARY_mpv ${CMAKE_CURRENT_SOURCE_DIR}/deps/lib/libmpv.dylib)
+  set(MPV_LIBRARY_mpv /opt/homebrew/opt/mpv/lib/libmpv.dylib)
   set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,@executable_path/../Frameworks")
   add_definitions("-pipe")
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -arch x86_64")
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -arch arm64")
   set(ENV{OPENSSL_ROOT_DIR} $ENV{OPENSSL_BIN_PATH})
 endif()
diff --git a/mac/finalize.sh b/mac/finalize.sh
old mode 100755
new mode 100644
index bd2e312..b23ca43
--- a/mac/finalize.sh
+++ b/mac/finalize.sh
@@ -6,20 +6,14 @@ TAG=${1:-master}
 
 DEST_DIR=./stremio.app/Contents/MacOS
 
-cp ./mac/ffmpeg $DEST_DIR/
-cp ./mac/ffprobe $DEST_DIR/
-cp $(which node) $DEST_DIR/
+cp -f $(which ffmpeg) $DEST_DIR/
+cp -f $(which ffprobe) $DEST_DIR/
+cp -f $(which node) $DEST_DIR/
 chmod +w $DEST_DIR/ffmpeg
 chmod +w $DEST_DIR/ffprobe
 chmod +w $DEST_DIR/node
 
 mkdir -p ./stremio.app/Contents/Frameworks
-cp ./deps/libmpv/mac/lib/*.dylib ./stremio.app/Contents/Frameworks/
-
-# https://bugreports.qt.io/browse/QTBUG-57265
-# you don't want to be using always-overwrite in any version until Qt 5.11.3
-macdeployqt ./stremio.app -executable=./stremio.app/Contents/MacOS/ffmpeg -executable=./stremio.app/Contents/MacOS/ffprobe -executable=./stremio.app/Contents/MacOS/node
 
 SHELL_VERSION=$(git grep -hoP '^\s*VERSION\s*=\s*\K.*$' HEAD -- stremio.pro)
 curl $(cat ./server-url.txt) > $DEST_DIR/server.js
-# ./mac/fix_osx_deps.sh "./stremio.app/Contents/Frameworks" "@executable_path/../Frameworks"
  1. Config, build and pack:
qmake CONFIG+=sdk_no_version_check
cmake -DCMAKE_PREFIX_PATH=/opt/homebrew/opt/qt@5 .
cmake --build .
chmod +x ./mac/finalize.sh && ./mac/finalize.sh
chmod +x ./mac/pack.sh && ./mac/pack.sh
  1. It will build Stremio 4.4.168.dmg in the directory, run it to install. Don't forget to enable hardware acceleration in Stremio settings.

This worked on my M4 Pro with macOS Sequoia, hopefully it works for someone else too.

Many thanks to everyone in this thread: https://www.reddit.com/r/Stremio/comments/15gijoq/stremio_for_apple_silicon_m1_m2_etc/

@zavan what node version are you using?

zavan commented

@zavan what node version are you using?

node -v
v22.11.0

I already had it installed via asdf.

thanks @zavan now latest one is 23 and it breaks dmg building, perhaps due some outdated function used

zavan commented

thanks @zavan now latest one is 23 and it breaks dmg building, perhaps due some outdated function used

Ah. In any case, I think the project should stick to the latest LTS version, which is v22. This helps minimize breaking changes.

Not sure if this will help anyone but I've used this successfully to get it working natively:
https://github.com/erfansamandarian/stremio-mac