scrcpy icon indicating copy to clipboard operation
scrcpy copied to clipboard

Please provide OS X binaries

Open alexhelder opened this issue 5 years ago • 30 comments

Not everyone with OS X can run homebrew. For example, enterprise management software may block homebrew.

alexhelder avatar Sep 03 '20 20:09 alexhelder

It would be great if there was an option to build scrcpy statically (with relevant parts of ffmpeg and sdl included). (#1624)

This would be easier to distribute a binary for other platforms.

rom1v avatar Sep 04 '20 06:09 rom1v

Anybody working on this issue? Really need it.

walkthunder avatar Feb 13 '21 04:02 walkthunder

I wanna work it out, but I'm not familar with the build system. So could you pls give me some hints, like:

how to prepare the dependencies(ffmpeg).

would this be helpful? https://gitlab.freedesktop.org/gstreamer/gst-build/-/blob/master/subprojects/FFmpeg.wrap I can see It generates each library's pkg_config file, inside it's meson.build

This way pkg_config knows where to find libavcodec/libavformat/.etc when building scrcpy.

would that work? @rom1v or what else need to be noticed?

walkthunder avatar Feb 16 '21 08:02 walkthunder

I am not familiar with macOS but will this work https://formulae.brew.sh/formula/ffmpeg?

Biswa96 avatar Feb 16 '21 09:02 Biswa96

@Biswa96 In this way ffmpeg linked as shared library. But here we need a static version of libavformat/libavcodec instead of dylibs.

And some related header files are also necessary, with which we can declare dependencies.

walkthunder avatar Feb 16 '21 10:02 walkthunder

+1 , its really ridicules to install 1GB+ source setup and other system overheads to use scrcpy on MacOS using brew . I don't know how it got popular even though it pulls Gigabytes to just update its database .

Genxster1998 avatar Jan 07 '22 19:01 Genxster1998

https://github.com/Genymobile/scrcpy#macos Is it the same with MacPorts?

rom1v avatar Jan 07 '22 19:01 rom1v

https://github.com/Genymobile/scrcpy#macos Is it the same with MacPorts?

On macports , macports default base installation size. is 500MB. On executing sudo port install scrcpy

--->  Computing dependencies for scrcpy
The following dependencies will be installed:
 Xft2
 XviD
 android-platform-tools
 aom
 autoconf
 autoconf-archive
 automake
 brotli
 bzip2
 cairo
 curl-ca-bundle
 dav1d
 db48
 expat
 ffmpeg
 fontconfig
 freetype
 fribidi
 gd2
 gdbm
 gdk-pixbuf2
 gettext
 gettext-runtime
 gettext-tools-libs
 giflib
 glib2
 gmp
 gnutls
 gobject-introspection
 graphite2
 graphviz
 gts
 harfbuzz
 icu
 jasper
 jbigkit
 lame
 lcms2
 libLASi
 libass
 libbluray
 libde265
 libedit
 libffi
 libheif
 libiconv
 libidn2
 libjpeg-turbo
 libmodplug
 libnetpbm
 libogg
 libopus
 libpixman
 libpng
 librsvg
 libsdl2
 libtasn1
 libtextstyle
 libtheora
 libtool
 libunistring
 libvorbis
 libvpx
 libxml2
 libxslt
 lz4
 m4
 ncurses
 nettle
 openjpeg
 openssl
 openssl3
 ossp-uuid
 p11-kit
 pango
 pcre
 perl5.28
 pkgconfig
 py39-beaker
 py39-mako
 py39-markdown
 py39-markupsafe
 py39-setuptools
 python39
 python3_select
 python_select
 rav1e
 readline
 shared-mime-info
 soxr
 speex
 sqlite3
 tiff
 urw-fonts
 vala
 webp
 x264
 x265
 xorg-libX11
 xorg-libXau
 xorg-libXaw
 xorg-libXdmcp
 xorg-libXext
 xorg-libXmu
 xorg-libXt
 xorg-libice
 xorg-libpthread-stubs
 xorg-libsm
 xorg-libxcb
 xorg-xcb-proto
 xorg-xcb-util
 xorg-xorgproto
 xpm
 xrender
 xz
 zimg
 zlib
 zstd
 zvbi

It essentially pulled whole linux distro ,lmao around 2.05GB just installing scrcpy nothing else. On Using HomeBrew

brew install scrcpy
==> Downloading https://ghcr.io/v2/homebrew/core/scrcpy/manifests/2.3.1
########################################################################################################################################################### 100.0%
==> Fetching dependencies for scrcpy: brotli, giflib, highway, imath, jpeg-turbo, libpng, xz, lz4, zstd, libtiff, little-cms2, openexr, webp, jpeg-xl, libvmaf, aom, aribb24, dav1d, freetype, fontconfig, frei0r, gmp, libunistring, libidn2, libtasn1, nettle, p11-kit, libevent, libnghttp2, unbound, gnutls, pcre2, glib, xorgproto, libxau, libxdmcp, libxcb, libx11, libxext, libxrender, lzo, pixman, cairo, graphite2, icu4c, harfbuzz, lame, fribidi, libunibreak, libass, libbluray, cjson, libmicrohttpd, mbedtls, librist, libsoxr, libssh, libvidstab, libogg, libvorbis, libvpx, opencore-amr, openjpeg, isl, mpfr, libmpc, gcc, openblas, numpy, pugixml, snappy, hwloc, tbb, openvino, opus, rav1e, libsamplerate, flac, mpg123, libsndfile, rubberband, sdl2, speex, srt, svt-av1, leptonica, libb2, libarchive, pango, tesseract, theora, x264, x265, xvid, libsodium, zeromq, zimg, ffmpeg and libusb

Screenshot 2022-01-08 at 9 27 18 PM

Genxster1998 avatar Jan 08 '22 15:01 Genxster1998

Could scrcpy be build with static libavcodec, libavutil, libavformat, libsdl2 and relevent headers ?

Genxster1998 avatar Jan 08 '22 15:01 Genxster1998

scrcpy for macOS

Coool avatar Sep 16 '22 22:09 Coool

@Coool just in case the news didn't reach you: scrcpy v.1.2.5 is out 🥇

LeeBinder avatar Dec 22 '22 20:12 LeeBinder

@LeeBinder I know. Can't keep up with all crap. Build scrcpy v1.25 release. Is it working?

Coool avatar Jan 08 '23 20:01 Coool

Great. We're here for fun not on the run .. ;) YES, working fine in Catalina, WELL DONE @Coool ! (can test in Ventura in a few days.)

Now most libs are compiled right into the binary, just leaving libSDL2-2.0.0 and libusb-1.0.0 as external dylibs. From what I know that usually indicates speed increase.

LeeBinder avatar Jan 08 '23 22:01 LeeBinder

I will try statically integrate other two, too. But still in progress to figure out.

Coool avatar Jan 08 '23 22:01 Coool

@Coool just for the sake of knowing: did you also use MacPorts in any way during the process of building/ compiling your fork?

LeeBinder avatar Mar 17 '23 17:03 LeeBinder

@LeeBinder, No. Build all dependencies from original sources at compile time.

Coool avatar Apr 11 '23 09:04 Coool

Gotcha. Have you tried compiling v.2.0 yet? Would like to compare differences with my MacPorts build.

LeeBinder avatar Apr 11 '23 18:04 LeeBinder

@LeeBinder, scrcpy v2.0 for macOS.

P.S. Report on which macOS version binary is working!

Coool avatar Apr 17 '23 23:04 Coool

Great, thank you @Coool . Less than 9MB compressed, that's impressive. It might be until Sunday nite that I can test in Ventura, Monterey and Big Sur and will let you know then 👍

LeeBinder avatar Apr 19 '23 08:04 LeeBinder

@LeeBinder, what your opinion do I need to create new issue suggestion which configure parameters to use for ffmpeg, SDL2 and libusb to optimize binary size? So we can squeeze more 👍.

Coool avatar Apr 19 '23 16:04 Coool

which configure parameters to use for ffmpeg

You can use the same as the ones used for the Windows release: https://github.com/rom1v/scrcpy-deps/

rom1v avatar Apr 19 '23 17:04 rom1v

@rom1v, are those parameters minimal required to scrcpy functional or we can disable some more not needed libraries function to squeeze as much as we can?

P.S. Anyway great work. I will try my best to translate documentation to Latvian. Already started with 1.2x, but you have made big progress on 2.0 documentation, so I need to catch up with your great categorized doc, help, wiki.

Coool avatar Apr 20 '23 13:04 Coool

are those parameters minimal required to scrcpy functional

It is the very minimal FFmpeg configuration with only the features used by scrcpy. The total size of the resulting dlls for Windows is 4.7Mb.

rom1v avatar Apr 20 '23 13:04 rom1v

Why do you need on Windows?

  • CFLAGS=-static-libgcc
  • LDFLAGS=-static-libgcc

Coool avatar Apr 20 '23 13:04 Coool

Without it, it fails at runtime with missing dll libgcc_s_dw2-1.dll.

https://github.com/rom1v/scrcpy-deps/blob/85d93b375a594574241a05a061d4fba9f522fa57/build_ffmpeg_windows.sh#L13

rom1v avatar Apr 20 '23 13:04 rom1v

@rom1v, check out scrcpy FFmpeg build script for macOS.

P.S. Strange can't compile scrcpy with your FFmpeg build parameters. All works great only with --disable-shared and --enable-static.

undef: _SecTaskCreateFromSelf undef: _SecTaskCopyValueForEntitlement Undefined symbols for architecture x86_64: "_SecTaskCreateFromSelf", referenced from: _darwin_detach_kernel_driver in libusb-1.0.a(darwin_usb.o) "_SecTaskCopyValueForEntitlement", referenced from: _darwin_detach_kernel_driver in libusb-1.0.a(darwin_usb.o)

Coool avatar Apr 20 '23 18:04 Coool

@Coool your build (even though compiled in the old macOS High Sierra) runs fine all the way up to the latest Ventura 13.3.1 (also tested in Monterey, Big Sur and Catalina). Apparently your FFmpeg build parameters are fine for macOS.

One suggestion regarding the path to scrcpy-server: can you make it relative rather than static to /Android/scrcpy/scrcpy-server? You can query the current path of the scrcpy binary with a command like cd "$(dirname "$0")" or simply pwd - depending on usage inside your code by assigning a variable like DIR=$( cd $(dirname $0) ; pwd) . Then both binaries, scrcpy and scrcpy-server, could be on the same level ("next to each other").

Also, in a second step, if you can assign a relative path in a way that the scrcpy binary looks for scrcpy-server in ../Resources, it might be possible to package both into an app package scrcpy.app 👍

In case you're curious about that, I've attached an app template zip for that purpose :)

scrcpy 2.0 (Coool) app template.zip

LeeBinder avatar Apr 23 '23 22:04 LeeBinder

@Coool we need you help , come on

hellokuan avatar Apr 30 '23 00:04 hellokuan

@hellokuan how do people usually react when someone is being pushy on them? Right, they most likely retract..

Also it's highly unlikely that it's possible to compile for Apple Silicon in the old macOS High Sierra.

Anyway, look here.

LeeBinder avatar Apr 30 '23 17:04 LeeBinder

@hellokuan, based on Stack Overflow article, you need at least Xcode version 12.2. Is it true, I don't know. Until you don't test yourself, don't trust anything what published on web. I'm using Xcode Version 10.1 (10B61) which is latest supported on macOS 10.13.6+ (High Sierra). I will check if it is feasible.

Coool avatar May 22 '23 08:05 Coool