diff --git a/app/meson.build b/app/meson.build index b182e443..89328326 100644 --- a/app/meson.build +++ b/app/meson.build @@ -25,14 +25,38 @@ src = [ 'src/util/str_util.c' ] +cc = meson.get_compiler('c') + if not get_option('crossbuild_windows') + avdir = get_option('local_libav') + if avdir != '' + message('Using local libav at ' + avdir) + libdir = meson.current_source_dir() + '/../' + avdir + '/lib' + incdir = '../' + avdir + '/include' + ffmpeg = declare_dependency( + dependencies: [ + cc.find_library('avformat', dirs : libdir), + cc.find_library('avcodec', dirs : libdir), + cc.find_library('avutil', dirs : libdir), + cc.find_library('swscale', dirs : libdir) + ], + include_directories: include_directories(incdir) + ) + else + ffmpeg = declare_dependency( + dependencies: [ + dependency('avformat'), + dependency('avcodec'), + dependency('avutil'), + dependency('swscale') + ] + ) + endif + # native build dependencies = [ - dependency('libavformat'), - dependency('libavcodec'), - dependency('libavutil'), - dependency('libswscale'), + ffmpeg, dependency('libpng'), dependency('sdl2'), ] @@ -76,8 +100,6 @@ else endif -cc = meson.get_compiler('c') - if host_machine.system() == 'windows' src += [ 'src/sys/win/command.c' ] dependencies += cc.find_library('ws2_32') diff --git a/app/src/capture.c b/app/src/capture.c index a4805927..509d3c6c 100644 --- a/app/src/capture.c +++ b/app/src/capture.c @@ -112,6 +112,9 @@ static bool in_frame_to_png( LOGV("Scaling image: %llu", get_timestamp() - start); + av_dict_set(&rgbFrame->metadata, + "Software", "scrcpy/" SCRCPY_VERSION, 0); + AVCodec *outCodec = avcodec_find_encoder(AV_CODEC_ID_PNG); if (!outCodec) { LOGE("Failed to find PNG codec"); diff --git a/meson_options.txt b/meson_options.txt index b962380c..3b4d5cef 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -6,3 +6,4 @@ option('portable', type: 'boolean', value: false, description: 'Use scrcpy-serve option('hidpi_support', type: 'boolean', value: true, description: 'Enable High DPI support') option('server_debugger', type: 'boolean', value: false, description: 'Run a server debugger and wait for a client to be attached') option('server_debugger_method', type: 'combo', choices: ['old', 'new'], value: 'new', description: 'Select the debugger method (Android < 9: "old", Android >= 9: "new")') +option('local_libav', type: 'string', value: '', description: 'Path to local installation of libav (ffmpeg)') diff --git a/mobot.mk b/mobot.mk new file mode 100644 index 00000000..7a3c48e8 --- /dev/null +++ b/mobot.mk @@ -0,0 +1,52 @@ +# Mobot makefile +# Build the Mobot version of scrcpy with Mobot's FFmpeg +# make -f mobot.mk +# On Linux it may be necessary to install dependencies +# sudo apt-get install cmake ninja libpng-dev libsdl2-dev libx264-dev +# pip3 install meson +# sudo snap install scrcpy (for server .jar) +# On Raspberry Pi it may be necessary to install +# sudo apt-get install ninja-build meson libudev1 libsdl2-dev + +.DEFAULT_GOAL := scrcpy + +AVDIR:=build-libav +AVLIBDIR:=$(AVDIR)/lib +AVLIBS:=$(AVLIBDIR)/libavformat.a $(AVLIBDIR)/libavcodec.a $(AVLIBDIR)/libavutil.a $(AVLIBDIR)/libswscale.a + +build-ffmpeg: + git clone https://github.com/team-mobot/FFmpeg.git build-ffmpeg + +$(AVLIBS): build-ffmpeg + # Build Mobot version of FFmpeg and install in subdir libav + cd build-ffmpeg && \ + git checkout release/4.3 && \ + ./configure --prefix="../build-libav" \ + --pkg-config-flags="--static" \ + --enable-gpl --enable-nonfree \ + --disable-bsfs --disable-filters \ + --disable-indevs --disable-outdevs \ + --disable-protocols --enable-protocol=file \ + --disable-muxers --enable-muxer=h264 \ + --disable-demuxers --enable-demuxer=h264 \ + --disable-parsers --enable-parser=h264,png \ + --disable-encoders --enable-encoder=png \ + --disable-decoders --enable-decoder=h264 \ + --enable-libx264 && \ + make install-libs install-headers + +build-app: $(AVLIBS) + LDFLAGS="-Wl,-lm -Wl,-lpthread" \ + meson build-app --buildtype release --strip -Db_lto=true \ + -Dlocal_libav=$(AVDIR) \ + -Dcompile_server=false \ + || (ret=$$?; rm -rf $@ && exit $$ret) + +scrcpy: build-app + ninja -Cbuild-app + +clean: + rm -rf build-ffmpeg build-libav build-app + +install: scrcpy + ninja -Cbuild-app install