Merge pull request #3 from team-mobot/ENG-2324-add-software-tag-to-png

ENG-2324 Add "Software" tag to PNG
This commit is contained in:
Frank Leon Rose 2021-04-13 17:42:36 -04:00 committed by GitHub
commit 49169bbc83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 84 additions and 6 deletions

View file

@ -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')

View file

@ -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");

View file

@ -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)')

52
mobot.mk Normal file
View file

@ -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