segmentation fault + ffmpeg parameter error + memory leaks
Environment
- OS: Manjaro
- scrcpy version: git c27ab46e
- installation method: meson setup d -Db_sanitize=address
- device model: Samsung S10e
- Android version: 12
Describe the bug scrcpy window is not opened, core dumped on segmentation fault.
$ ./run d
scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO: --> (usb) XXX device SM_G970F
DEBUG: Device serial: XXX
DEBUG: Using SCRCPY_SERVER_PATH: d/server/scrcpy-server
d/server/scrcpy-server: 1 file pushed, 0 skipped. 161.2 MB/s (96676 bytes in 0.001s)
[server] INFO: Device: [samsung] samsung SM-G970F (Android 12)
DEBUG: Server connected
DEBUG: Starting controller thread
DEBUG: Starting receiver thread
[server] DEBUG: Using audio encoder: 'c2.android.opus.encoder'
[server] DEBUG: Using video encoder: 'OMX.Exynos.AVC.Encoder'
[server] DEBUG: Display: using SurfaceControl API
INFO: Renderer: opengl
INFO: OpenGL version: 4.6.0 NVIDIA 550.54.14
INFO: Trilinear filtering enabled
DEBUG: Using SCRCPY_ICON_PATH: app/data/icon.png
AddressSanitizer:DEADLYSIGNAL
=================================================================
==620474==ERROR: AddressSanitizer: SEGV on unknown address 0x0000bfff8000 (pc 0x56455f163e3e bp 0x7ffcbab78680 sp 0x7ffcbab78570 T0)
==620474==The signal is caused by a READ memory access.
#0 0x56455f163e3e in decode_image ../app/src/icon.c:89
#1 0x56455f164510 in load_from_path ../app/src/icon.c:192
#2 0x56455f164e92 in scrcpy_icon_load ../app/src/icon.c:280
#3 0x56455f18130d in sc_screen_init ../app/src/screen.c:411
#4 0x56455f17dbae in scrcpy ../app/src/scrcpy.c:721
#5 0x56455f1455b7 in main_scrcpy ../app/src/main.c:88
#6 0x56455f1456db in main ../app/src/main.c:107
#7 0x7fbad4c76ccf (/usr/lib/libc.so.6+0x29ccf) (BuildId: 0865c4b9ba13e0094e8b45b78dfc7a2971f536d2)
#8 0x7fbad4c76d89 in __libc_start_main (/usr/lib/libc.so.6+0x29d89) (BuildId: 0865c4b9ba13e0094e8b45b78dfc7a2971f536d2)
#9 0x56455f145014 in _start (/mnt/d/GitHub/scrcpy/d/app/scrcpy+0x2b014) (BuildId: 626a8249afe58faf1f06254862a3863b1ad86115)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV ../app/src/icon.c:89 in decode_image
==620474==ABORTING
[server] DEBUG: Controller stopped
[server] DEBUG: Device message sender stopped
[server] DEBUG: Screen streaming stopped
[server] DEBUG: Audio encoder stopped
So I tried running without an actual icon:
$ SCRCPY_SERVER_PATH=d/server/scrcpy-server SCRCPY_ICON_PATH="dev/null" d/app/scrcpy -V debug
scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO: --> (usb) XXX device SM_G970F
DEBUG: Device serial: XXX
DEBUG: Using SCRCPY_SERVER_PATH: d/server/scrcpy-server
d/server/scrcpy-server: 1 file pushed, 0 skipped. 156.2 MB/s (96676 bytes in 0.001s)
[server] INFO: Device: [samsung] samsung SM-G970F (Android 12)
DEBUG: Server connected
DEBUG: Starting controller thread
DEBUG: Starting receiver thread
[server] DEBUG: Using video encoder: 'OMX.Exynos.AVC.Encoder'
[server] DEBUG: Using audio encoder: 'c2.android.opus.encoder'
[server] DEBUG: Display: using SurfaceControl API
INFO: Renderer: opengl
INFO: OpenGL version: 4.6.0 NVIDIA 550.54.14
INFO: Trilinear filtering enabled
DEBUG: Using SCRCPY_ICON_PATH: dev/null
ERROR: Could not open icon image: dev/null
WARN: Could not load icon
DEBUG: Demuxer 'video': starting thread
DEBUG: Demuxer 'audio': starting thread
INFO: Texture: 1080x2280
ERROR: [FFmpeg] Value -619858224 for parameter 'in_sample_fmt' out of sample format range [-1 - 11]
ERROR: [FFmpeg] Requested input sample format -1 is invalid
ERROR: Failed to initialize the resampling context
ERROR: Demuxer error
DEBUG: quit...
DEBUG: Receiver stopped
[server] DEBUG: Controller stopped
[server] DEBUG: Device message sender stopped
[server] DEBUG: Audio encoder stopped
DEBUG: Demuxer 'video': end of frames
WARN: Killing the server...
DEBUG: Server disconnected
DEBUG: Server terminated
=================================================================
==716268==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 184 byte(s) in 1 object(s) allocated from:
#0 0x7f8fdc8fc34a in calloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:77
#1 0x7f8fca0b1d8a (/usr/lib/libdbus-1.so.3+0x23d8a) (BuildId: 2e5c986493292691de71f15154efb3214e0a4f5f)
Indirect leak of 1842 byte(s) in 2 object(s) allocated from:
#0 0x7f8fdc8fb6e2 in realloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:85
#1 0x7f8fca0bfa4f (/usr/lib/libdbus-1.so.3+0x31a4f) (BuildId: 2e5c986493292691de71f15154efb3214e0a4f5f)
SUMMARY: AddressSanitizer: 2026 byte(s) leaked in 3 allocation(s).
The ffmpeg binary is from package ffmpeg 2:6.1.1-7 from the manjaro extra repository
$ command ffmpeg
ffmpeg version n6.1.1 Copyright (c) 2000-2023 the FFmpeg developers
built with gcc 13.2.1 (GCC) 20230801
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-amf --enable-avisynth --enable-cuda-llvm --enable-lto --enable-fontconfig --enable-frei0r --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libharfbuzz --enable-libiec61883 --enable-libjack --enable-libjxl --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libplacebo --enable-libpulse --enable-librav1e --enable-librsvg --enable-librubberband --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpl --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-nvdec --enable-nvenc --enable-opencl --enable-opengl --enable-shared --enable-vapoursynth --enable-version3 --enable-vulkan
libavutil 58. 29.100 / 58. 29.100
libavcodec 60. 31.102 / 60. 31.102
libavformat 60. 16.100 / 60. 16.100
libavdevice 60. 3.100 / 60. 3.100
libavfilter 9. 12.100 / 9. 12.100
libswscale 7. 5.100 / 7. 5.100
libswresample 4. 12.100 / 4. 12.100
libpostproc 57. 3.100 / 57. 3.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
Use -h to get full help or, even better, run 'man ffmpeg'
OTG mode works:
$ SCRCPY_SERVER_PATH=d/server/scrcpy-server SCRCPY_ICON_PATH="dev/null" d/app/scrcpy --otg
scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
DEBUG: Open USB device XXX:YYYY: libusb error: Access denied (insufficient permissions)
DEBUG: Open USB device XX:YYYY: libusb error: Access denied (insufficient permissions)
DEBUG: Open USB device XXX:YYYY: libusb error: Access denied (insufficient permissions)
DEBUG: Open USB device XXX:YYYY: libusb error: Access denied (insufficient permissions)
DEBUG: Open USB device XXX:YYYY: libusb error: Access denied (insufficient permissions)
DEBUG: Open USB device XXX:YYYY: libusb error: Access denied (insufficient permissions)
INFO: USB device found:
INFO: --> XXX (04e8:6860) SAMSUNG SAMSUNG_Android
DEBUG: Starting AOA thread
DEBUG: Using SCRCPY_ICON_PATH: dev/null
ERROR: Could not open icon image: dev/null
WARN: Could not load icon
DEBUG: HID keyboard state synchronized
^CDEBUG: User requested to quit
DEBUG: quit...
=================================================================
==732119==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 1684064 byte(s) in 102 object(s) allocated from:
#0 0x7f6658efca31 in malloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:69
#1 0x7f663ade8961 (/usr/lib/libnvidia-glcore.so.550.54.14+0x9e8961) (BuildId: 5b1ef0cc938d5484c92f017ff5166705223f1d4d)
Direct leak of 270291 byte(s) in 59 object(s) allocated from:
#0 0x7f6658efc34a in calloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:77
#1 0x7f663ade8c1d (/usr/lib/libnvidia-glcore.so.550.54.14+0x9e8c1d) (BuildId: 5b1ef0cc938d5484c92f017ff5166705223f1d4d)
Direct leak of 184 byte(s) in 1 object(s) allocated from:
#0 0x7f6658efc34a in calloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:77
#1 0x7f6646634d8a (/usr/lib/libdbus-1.so.3+0x23d8a) (BuildId: 2e5c986493292691de71f15154efb3214e0a4f5f)
Indirect leak of 304108 byte(s) in 236 object(s) allocated from:
#0 0x7f6658efc34a in calloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:77
#1 0x7f663ade8c1d (/usr/lib/libnvidia-glcore.so.550.54.14+0x9e8c1d) (BuildId: 5b1ef0cc938d5484c92f017ff5166705223f1d4d)
Indirect leak of 121585 byte(s) in 1012 object(s) allocated from:
#0 0x7f6658efca31 in malloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:69
#1 0x7f663ade8961 (/usr/lib/libnvidia-glcore.so.550.54.14+0x9e8961) (BuildId: 5b1ef0cc938d5484c92f017ff5166705223f1d4d)
Indirect leak of 1842 byte(s) in 2 object(s) allocated from:
#0 0x7f6658efb6e2 in realloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:85
#1 0x7f6646642a4f (/usr/lib/libdbus-1.so.3+0x31a4f) (BuildId: 2e5c986493292691de71f15154efb3214e0a4f5f)
Indirect leak of 336 byte(s) in 1 object(s) allocated from:
#0 0x7f6658efb6e2 in realloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:85
#1 0x7f663ade8ff3 (/usr/lib/libnvidia-glcore.so.550.54.14+0x9e8ff3) (BuildId: 5b1ef0cc938d5484c92f017ff5166705223f1d4d)
SUMMARY: AddressSanitizer: 2382410 byte(s) leaked in 1413 allocation(s).
Thank you for your report.
Leaks come from other libs (dbus and nvidia driver).
For the segfault, I will investigate. Please post the full result of scrcpy --version.
scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
Dependencies (compiled / linked):
- SDL: 2.30.0 / 2.30.3
- libavcodec: 58.125.101 / 60.31.102
- libavformat: 58.68.100 / 60.16.100
- libavutil: 56.66.100 / 58.29.100
- libavdevice: 58.12.100 / 60.3.100
- libusb: - / 1.0.27
How was your ffmpeg compiled?
It seems you compiled scrcpy against an old version but linked a newer version. It should be perfectly ok, but It is surprising, since you're building manually.
I can't understand/reproduce your segfault.
Could you try on dev branch? Also, I prepared a minor change that impacts the line where you segfaults: icon_decoder. Could you please test this branch?
It seems you compiled scrcpy against an old version but linked a newer version. It should be perfectly ok,
Oh, no, it is not perfectly ok since they have a different major number, they are not ABI compatible:
FFmpeg guarantees backward API and ABI compatibility for each library as long as its major version number is unchanged.
You get other similar errors related to this incompatibility:
ERROR: [FFmpeg] Value -619858224 for parameter 'in_sample_fmt' out of sample format range [-1 - 11] ERROR: [FFmpeg] Requested input sample format -1 is invalid
How was your ffmpeg compiled?
The ffmpeg binary is from package ffmpeg 2:6.1.1-7 from the manjaro extra repository
You can see the PKGBUILD here: https://gitlab.archlinux.org/archlinux/packaging/packages/ffmpeg/-/blob/169a765abd4a55ae622dbcc3f7051b15c472a65d/PKGBUILD
It seems you compiled scrcpy against an old version but linked a newer version.
How can you tell ?
It seems you compiled scrcpy against an old version but linked a newer version.
How can you tell ?
Dependencies (compiled / linked):
[…]
- libavcodec: 58.125.101 / 60.31.102
- libavformat: 58.68.100 / 60.16.100
- libavutil: 56.66.100 / 58.29.100
- libavdevice: 58.12.100 / 60.3.100
[…]
You must recompile scrcpy (against your current ffmpeg libraries).
I prepared a minor change that impacts the line where you segfaults:
icon_decoder. Could you please test this branch?
$ git fetch origin icon_decoder
$ git checkout icon_decoder
$ ./install_release.sh
...
Found ninja-1.12.1 at /usr/bin/ninja
[33/69] Compiling C object app/scrcpy.p/src_icon.c.o
FAILED: app/scrcpy.p/src_icon.c.o
ccache cc -Iapp/scrcpy.p -Iapp -I../app -I../app/src -I/usr/include/SDL2 -I/usr/include/libusb-1.0 -flto=auto -fdiagnostics-color=always -DNDEBUG -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=c11 -O3 -Wmissing-prototypes -D_REENTRANT -MD -MQ app/scrcpy.p/src_icon.c.o -MF app/scrcpy.p/src_icon.c.o.d -o app/scrcpy.p/src_icon.c.o -c ../app/src/icon.c
../app/src/icon.c: In function ‘decode_image’:
../app/src/icon.c:84:62: error: passing argument 5 of ‘av_find_best_stream’ from incompatible pointer type [-Wincompatible-pointer-types]
84 | av_find_best_stream(ctx, AVMEDIA_TYPE_VIDEO, -1, -1, &codec, 0);
| ^~~~~~
| |
| const AVCodec **
In file included from ../app/src/icon.h:8,
from ../app/src/icon.c:1:
/usr/local/include/libavformat/avformat.h:2281:35: note: expected ‘AVCodec **’ but argument is of type ‘const AVCodec **’
2281 | AVCodec **decoder_ret,
| ~~~~~~~~~~^~~~~~~~~~~
[50/69] Compiling C object app/scrcpy.p/src_scrcpy.c.o
ninja: build stopped: subcommand failed.
Could you try on
devbranch?
$ git checkout dev
$ ./install_release.sh
...
$ /usr/local/bin/scrcpy -V debug
scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO: --> (usb) XXX device SM_G970F
DEBUG: Device serial: XXX
DEBUG: Using server: /usr/local/share/scrcpy/scrcpy-server
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 135.7 MB/s (69007 bytes in 0.000s)
[server] INFO: Device: [samsung] samsung SM-G970F (Android 12)
DEBUG: Server connected
DEBUG: Starting controller thread
DEBUG: Starting receiver thread
INFO: Renderer: opengl
INFO: OpenGL version: 4.6.0 NVIDIA 550.54.14
INFO: Trilinear filtering enabled
DEBUG: Using icon: /usr/local/share/icons/hicolor/256x256/apps/scrcpy.png
[server] DEBUG: Using audio encoder: 'c2.android.opus.encoder'
[server] DEBUG: Using video encoder: 'OMX.Exynos.AVC.Encoder'
[server] DEBUG: Display: using SurfaceControl API
[server] DEBUG: Controller stopped
[server] DEBUG: Device message sender stopped
[1] 448189 segmentation fault (core dumped) /usr/local/bin/scrcpy -V debug
[server] DEBUG: Audio encoder stopped
[server] DEBUG: Screen streaming stopped
/usr/local/include/libavformat/avformat.h:2281:35: note: expected ‘AVCodec **’ but argument is of type ‘const AVCodec **’ 2281 | AVCodec **decoder_ret, | ~~~~~~~~~~^~~~~~~~~~~
Please test with this additional change:
diff --git a/app/src/icon.c b/app/src/icon.c
index 52537d2ba..0dddefa3c 100644
--- a/app/src/icon.c
+++ b/app/src/icon.c
@@ -78,7 +78,16 @@ decode_image(const char *path) {
goto close_input;
}
+
+// In ffmpeg/doc/APIchanges:
+// 2021-04-27 - 46dac8cf3d - lavf 59.0.100 - avformat.h
+// av_find_best_stream now uses a const AVCodec ** parameter
+// for the returned decoder.
+#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(59, 0, 100)
const AVCodec *codec;
+#else
+ AVCodec *codec;
+#endif
int stream =
av_find_best_stream(ctx, AVMEDIA_TYPE_VIDEO, -1, -1, &codec, 0);
If it build for you, I'll merge it into dev.
$ git checkout dev $ ./install_release.sh
Note: in theory, the prebuilt server is only built for each release, so the client on dev branch might be incompatible with the prebuilt server. But in any case, it should NEVER segfault.
[1] 448189 segmentation fault (core dumped) /usr/local/bin/scrcpy -V debug
What is the result of /usr/local/bin/scrcpy -v?
You must recompile scrcpy (against your current ffmpeg libraries).
isn't that what ./install_release.sh supposed to do ? I'm getting the same compiled/linked discrepancies after it
isn't that what ./install_release.sh supposed to do ?
Yes.
I'm getting the same compiled/linked discrepancies after it
So with the same compiled and link dependencies, you still get the segfault? I could not reproduce.
Please retry in debug and with ASAN enabled:
diff --git a/install_release.sh b/install_release.sh
index 0be5675c6..478297702 100755
--- a/install_release.sh
+++ b/install_release.sh
@@ -12,7 +12,7 @@ echo "$PREBUILT_SERVER_SHA256 scrcpy-server" | sha256sum --check
echo "[scrcpy] Building client..."
rm -rf "$BUILDDIR"
-meson setup "$BUILDDIR" --buildtype=release --strip -Db_lto=true \
+meson setup "$BUILDDIR" --buildtype=debug -Db_sanitize=address \
-Dprebuilt_server=scrcpy-server
cd "$BUILDDIR"
ninja
If it build for you
on icon_decoder it builds but after patching I get:
$ d_ic/app/scrcpy -V debug
...
DEBUG: Using icon: /usr/local/share/icons/hicolor/256x256/apps/scrcpy.png
AddressSanitizer:DEADLYSIGNAL
=================================================================
==491268==ERROR: AddressSanitizer: SEGV on unknown address 0x000200000004 (pc 0x7f4b4de064ef bp 0x7ffed0dd9e30 sp 0x7ffed0dd9cd0 T0)
==491268==The signal is caused by a READ memory access.
#0 0x7f4b4de064ef in avcodec_parameters_to_context (/usr/lib/libavcodec.so.60+0x2064ef) (BuildId: 6062be614616d2aaa7b103b2fd6bcf17aa07e92d)
#1 0x55d6e5c1eafe in decode_image ../app/src/icon.c:107
#2 0x55d6e5c1f0eb in load_from_path ../app/src/icon.c:198
#3 0x55d6e5c1fa6d in scrcpy_icon_load ../app/src/icon.c:286
#4 0x55d6e5c3ca06 in sc_screen_init ../app/src/screen.c:449
#5 0x55d6e5c38d4c in scrcpy ../app/src/scrcpy.c:743
#6 0x55d6e5bff5c7 in main_scrcpy ../app/src/main.c:88
#7 0x55d6e5bff6eb in main ../app/src/main.c:107
#8 0x7f4b4c676ccf (/usr/lib/libc.so.6+0x29ccf) (BuildId: 0865c4b9ba13e0094e8b45b78dfc7a2971f536d2)
#9 0x7f4b4c676d89 in __libc_start_main (/usr/lib/libc.so.6+0x29d89) (BuildId: 0865c4b9ba13e0094e8b45b78dfc7a2971f536d2)
#10 0x55d6e5bff024 in _start (/mnt/d/GitHub/scrcpy/d_ic/app/scrcpy+0x2c024) (BuildId: 929ae4336a7de23d01a90ae593bdbb736612a0da)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/usr/lib/libavcodec.so.60+0x2064ef) (BuildId: 6062be614616d2aaa7b103b2fd6bcf17aa07e92d) in avcodec_parameters_to_context
==491268==ABORTING
[server] DEBUG: Using video encoder: 'OMX.Exynos.AVC.Encoder'
[server] DEBUG: Using audio encoder: 'c2.android.opus.encoder'
[server] DEBUG: Display: using SurfaceControl API
[server] DEBUG: Controller stopped
[server] DEBUG: Device message sender stopped
[server] DEBUG: Audio encoder stopped
[server] DEBUG: Screen streaming stopped
on icon_decoder it builds
:+1:
The fact that you need this patch suggests that you're building for an old version (otherwise you'll get the new API).
What is the result of scrcpy -v with your new build?
What is the result of
scrcpy -vwith your new build?
scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
Dependencies (compiled / linked):
- SDL: 2.30.3 / 2.30.3
- libavcodec: 58.125.101 / 60.31.102
- libavformat: 58.68.100 / 60.16.100
- libavutil: 56.66.100 / 58.29.100
- libavdevice: 58.12.100 / 60.3.100
- libusb: - / 1.0.27
OK so you build against an old ffmpeg and run against a newer one:
- libavcodec: 58.125.101 / 60.31.102
- libavformat: 58.68.100 / 60.16.100
- libavutil: 56.66.100 / 58.29.100
- libavdevice: 58.12.100 / 60.3.100
So with the same compiled and link dependencies, you still get the segfault? I could not reproduce.
Please retry in debug and with ASAN enabled:
same error in both master & dev branches.
OK so you build against an old ffmpeg and run against a newer one:
That's weird because I only have one ffmpeg binary installed
pkg-config --print-provides libavformat
pkg-config --print-provides libavformat
libavformat = 60.16.100
That's the new version (so it's correct).
If you create a builddir, what is the full output:
meson setup tmpbuilddir
$ meson setup tmpbuilddir
The Meson build system
Version: 1.4.0
Source dir: /mnt/d/GitHub/scrcpy
Build dir: /mnt/d/GitHub/scrcpy/tmpbuilddir
Build type: native build
Project name: scrcpy
Project version: 2.4
C compiler for the host machine: ccache cc (gcc 14.1.1 "cc (GCC) 14.1.1 20240507")
C linker for the host machine: cc ld.bfd 2.42.0
Host machine cpu family: x86_64
Host machine cpu: x86_64
Found pkg-config: YES (/usr/bin/pkg-config) 2.1.1
Run-time dependency libavformat found: YES 60.16.100
Run-time dependency libavcodec found: YES 60.31.102
Run-time dependency libavutil found: YES 58.29.100
Run-time dependency libswresample found: YES 4.12.100
Run-time dependency sdl2 found: YES 2.30.3
Run-time dependency libavdevice found: YES 60.3.100
Run-time dependency libusb-1.0 found: YES 1.0.27
Checking for function "strdup" : YES
Checking for function "asprintf" : YES
Checking for function "vasprintf" : YES
Checking for function "nrand48" : YES
Checking for function "jrand48" : YES
Checking for function "reallocarray" : YES
Header "sys/socket.h" has symbol "SOCK_CLOEXEC" : YES
Configuring config.h using configuration
Program ./scripts/build-wrapper.sh found: YES (/mnt/d/GitHub/scrcpy/server/./scripts/build-wrapper.sh)
Build targets in project: 13
Found ninja-1.12.1 at /usr/bin/ninja
Run-time dependency libavformat found: YES 60.16.100 Run-time dependency libavcodec found: YES 60.31.102 Run-time dependency libavutil found: YES 58.29.100 Run-time dependency libswresample found: YES 4.12.100 Run-time dependency sdl2 found: YES 2.30.3 Run-time dependency libavdevice found: YES 60.3.100 Run-time dependency libusb-1.0 found: YES 1.0.27
OK, that looks correct, so now if you build, you'll get the correct version:
ninja -Ctmpbuilddir
./run tmpbuilddir -v
./run tmpbuilddir
$ ./run tmpbuilddir -v
scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
Dependencies (compiled / linked):
- SDL: 2.30.3 / 2.30.3
- libavcodec: 58.125.101 / 60.31.102
- libavformat: 58.68.100 / 60.16.100
- libavutil: 56.66.100 / 58.29.100
- libavdevice: 58.12.100 / 60.3.100
- libusb: - / 1.0.27
Same issue:
$ SCRCPY_ICON_PATH="dev/null" tmpbuilddir/app/scrcpy -V debug
...
ERROR: [FFmpeg] Value -510806320 for parameter 'in_sample_fmt' out of sample format range [-1 - 11]
ERROR: [FFmpeg] Requested input sample format -1 is invalid
...
Found pkg-config: YES (/usr/bin/pkg-config) 2.1.1 Run-time dependency libavformat found: YES 60.16.100 Run-time dependency libavcodec found: YES 60.31.102 Run-time dependency libavutil found: YES 58.29.100 Run-time dependency libswresample found: YES 4.12.100 Run-time dependency sdl2 found: YES 2.30.3 Run-time dependency libavdevice found: YES 60.3.100 Run-time dependency libusb-1.0 found: YES 1.0.27
$ ./run tmpbuilddir -v scrcpy 2.4 <https://github.com/Genymobile/scrcpy> Dependencies (compiled / linked): - SDL: 2.30.3 / 2.30.3 - libavcodec: 58.125.101 / 60.31.102 - libavformat: 58.68.100 / 60.16.100 - libavutil: 56.66.100 / 58.29.100 - libavdevice: 58.12.100 / 60.3.100 - libusb: - / 1.0.27
WTF!?
Meson correctly detects libavformat 60.16.100, but LIBAVFORMAT_VERSION_MAJOR is 58 and LIBAVFORMAT_VERSION_MINOR is 68 :thinking:
https://github.com/Genymobile/scrcpy/blob/c27ab46efbcab0b9558a91e691d799ffef496c97/app/src/version.c#L32-L39
IMO there is something wrong with your ffmpeg headers or pkg-config.
Look at the version numbers in all your version_major.h files:
fd version_major.h /usr
What is the value of LIBAVFORMAT_VERSION_MAJOR in which directory? Do you have ffmpeg headers both in /usr and /usr/local?
@rom1v Hi and sorry for the late reply.
What is the value of
LIBAVFORMAT_VERSION_MAJORin which directory?
#define LIBAVFORMAT_VERSION_MAJOR 60
at /usr/include/libavformat/version_major.h
owned by package ffmpeg 2:6.1.1-7
Do you have ffmpeg headers both in /usr and /usr/local?
No not headers but I have some .a and .pc files for libav* libraries.
I also have ffmpeg 4.4 installed but it doesn't include any version_major.h files but has these .so files:
ffmpeg4.4 /usr/lib/libavcodec.so.58
ffmpeg4.4 /usr/lib/libavcodec.so.58.134.100
ffmpeg4.4 /usr/lib/libavdevice.so.58
ffmpeg4.4 /usr/lib/libavdevice.so.58.13.100
ffmpeg4.4 /usr/lib/libavfilter.so.7
ffmpeg4.4 /usr/lib/libavfilter.so.7.110.100
ffmpeg4.4 /usr/lib/libavformat.so.58
ffmpeg4.4 /usr/lib/libavformat.so.58.76.100
ffmpeg4.4 /usr/lib/libavutil.so.56
ffmpeg4.4 /usr/lib/libavutil.so.56.70.100
ffmpeg4.4 /usr/lib/libpostproc.so.55
ffmpeg4.4 /usr/lib/libpostproc.so.55.9.100
ffmpeg4.4 /usr/lib/libswresample.so.3
ffmpeg4.4 /usr/lib/libswresample.so.3.9.100
ffmpeg4.4 /usr/lib/libswscale.so.5
ffmpeg4.4 /usr/lib/libswscale.so.5.9.100
Inspecting the "local" .pc files it seemed the culprit was found.
Their versions fit 'scrcpy -v' output.
For example, in /usr/local/lib/pkgconfig/libavformat.pc it says:
Version: 58.68.100
I also checked:
$ pkg-config --print-provides libavformat
libavformat = 60.16.100
$ pkg-config --path libavformat
/usr/lib/pkgconfig/libavformat.pc
But even after deleting those files, deleting the local repository, recloning and building afresh the same version numbers show up with './run d -v'