Open alexhelder opened 4 years ago
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.
Anybody working on this issue? Really need it.
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?
I am not familiar with macOS but will this work https://formulae.brew.sh/formula/ffmpeg?
@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.
+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 .
https://github.com/Genymobile/scrcpy#macos Is it the same with MacPorts?
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
Could scrcpy be build with static libavcodec, libavutil, libavformat, libsdl2 and relevent headers ?
@Coool just in case the news didn't reach you: scrcpy v.1.2.5 is out 🥇
@LeeBinder I know. Can't keep up with all crap. Build scrcpy v1.25 release. Is it working?
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.
I will try statically integrate other two, too. But still in progress to figure out.
@Coool just for the sake of knowing: did you also use MacPorts in any way during the process of building/ compiling your fork?
@LeeBinder, No. Build all dependencies from original sources at compile time.
Gotcha. Have you tried compiling v.2.0 yet? Would like to compare differences with my MacPorts build.
@LeeBinder, scrcpy v2.0 for macOS.
P.S. Report on which macOS version binary is working!
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, 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 👍.
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, 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.
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.
Why do you need on Windows?
Without it, it fails at runtime with missing dll libgcc_s_dw2-1.dll
.
@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 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 :)
@Coool we need you help , come on
@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.
@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.
Not everyone with OS X can run homebrew. For example, enterprise management software may block homebrew.