前言:我本地使用的ubuntu系统版本是20.04,但是我现在需要更新的版本。所以,我就按照以下步骤安装最新版本的scrcpy!
参考:https://gitcode.com/gh_mirrors/sc/scrcpy/blob/master/doc/linux.md
bash
# Step1:安装必要的依赖
$ sudo apt install ffmpeg libsdl2-2.0-0 adb wget \
gcc git pkg-config meson ninja-build libsdl2-dev \
libavcodec-dev libavdevice-dev libavformat-dev libavutil-dev \
libswresample-dev libusb-1.0-0 libusb-1.0-0-dev
# Step2:从github上下载代码
$ git clone https://github.com/Genymobile/scrcpy
$ cd scrcpy #进入到代码路径
为了编译通过,需要修改部分代码:
bash
$ git diff
diff --git a/app/src/decoder.c b/app/src/decoder.c
index 4d0a1daf..a72f7196 100644
--- a/app/src/decoder.c
+++ b/app/src/decoder.c
@@ -1,7 +1,8 @@
#include "decoder.h"
#include <errno.h>
-#include <libavcodec/packet.h>
+//#include <libavcodec/packet.h>
+#include <libavcodec/avcodec.h>
#include <libavutil/avutil.h>
#include "util/log.h"
diff --git a/app/src/packet_merger.h b/app/src/packet_merger.h
index 3f9972ce..6b20da13 100644
--- a/app/src/packet_merger.h
+++ b/app/src/packet_merger.h
@@ -5,7 +5,8 @@
#include <stdbool.h>
#include <stdint.h>
-#include <libavcodec/packet.h>
+// #include <libavcodec/packet.h>
+#include <libavcodec/avcodec.h>
/**
* Config packets (containing the SPS/PPS) are sent in-band. A new config
diff --git a/app/src/recorder.h b/app/src/recorder.h
index 70b73836..44711b08 100644
--- a/app/src/recorder.h
+++ b/app/src/recorder.h
@@ -5,7 +5,8 @@
#include <stdbool.h>
#include <stdint.h>
-#include <libavcodec/packet.h>
+// #include <libavcodec/packet.h>
+#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include "options.h"
执行编译安装:
bash
$ ./install_release.sh
# 没有意外的话,就能够编译成功了,检查一下scrcpy的版本
$ scrcpy --version
scrcpy 3.3.4 <https://github.com/Genymobile/scrcpy>
Dependencies (compiled / linked):
- SDL: 2.0.10 / 2.0.10
- libavcodec: 58.54.100 / 58.54.100
- libavformat: 58.29.100 / 58.29.100
- libavutil: 56.31.100 / 56.31.100
- libavdevice: 58.8.100 / 58.8.100
- libusb: - / 1.0.28
$ which scrcpy
/usr/local/bin/scrcpy
同时附上编译log,如果编译结束后scrcpy的版本没有更新到新版本,请检查log中相关生成物安装的位置:
scrcpy\] Downloading prebuilt server... --2026-01-06 17:15:32-- https://github.com/Genymobile/scrcpy/releases/download/v3.3.4/scrcpy-server-v3.3.4 Resolving github.com (github.com)... 20.205.243.166 Connecting to github.com (github.com)\|20.205.243.166\|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://release-assets.githubusercontent.com/github-production-release-asset/111583593/e71a9a0c-7793-4ca1-8160-506c37dd2a4c?sp=r\&sv=2018-11-09\&sr=b\&spr=https\&se=2026-01-06T10%3A01%3A29Z\&rscd=attachment%3B+filename%3Dscrcpy-server-v3.3.4\&rsct=application%2Foctet-stream\&skoid=96c2d410-5711-43a1-aedd-ab1947aa7ab0\&sktid=398a6654-997b-47e9-b12b-9515b896b4de\&skt=2026-01-06T09%3A00%3A52Z\&ske=2026-01-06T10%3A01%3A29Z\&sks=b\&skv=2018-11-09\&sig=SbIhBhdL2AUa18kouNq1n2cQdcc5OJ3a%2BJqp8LDIV%2FM%3D\&jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmVsZWFzZS1hc3NldHMuZ2l0aHVidXNlcmNvbnRlbnQuY29tIiwia2V5Ijoia2V5MSIsImV4cCI6MTc2NzY5MTE1NiwibmJmIjoxNzY3NjkwODU2LCJwYXRoIjoicmVsZWFzZWFzc2V0cHJvZHVjdGlvbi5ibG9iLmNvcmUud2luZG93cy5uZXQifQ.SG0TBPsQD1EhnuMg4g3iirWtfQ4vYIXe-_7H0kJ1bjQ\&response-content-disposition=attachment%3B%20filename%3Dscrcpy-server-v3.3.4\&response-content-type=application%2Foctet-stream \[following
Resolving release-assets.githubusercontent.com (release-assets.githubusercontent.com)... 185.199.111.133, 185.199.109.133, 185.199.110.133
Connecting to release-assets.githubusercontent.com (release-assets.githubusercontent.com)|185.199.111.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 90980 (89K) [application/octet-stream]
Saving to: 'scrcpy-server'
scrcpy-server 100%[===============================================>] 88.85K 330KB/s in 0.3s
2026-01-06 17:15:33 (330 KB/s) - 'scrcpy-server' saved [90980/90980]
scrcpy\] Verifying prebuilt server...
scrcpy-server: OK
\[scrcpy\] Building client...
The Meson build system
Version: 0.53.2
Source dir: /home/bushuping/workspace/tools/myscrcpy/scrcpy
Build dir: /home/bushuping/workspace/tools/myscrcpy/scrcpy/build-auto
Build type: native build
Project name: scrcpy
Project version: 3.3.4
C compiler for the host machine: cc (gcc 9.4.0 "cc (Ubuntu 9.4.0-1ubuntu1\~20.04.3) 9.4.0")
C linker for the host machine: cc ld.bfd 2.34
Host machine cpu family: x86_64
Host machine cpu: x86_64
Found pkg-config: /usr/bin/pkg-config (0.29.1)
Run-time dependency libavformat found: YES 58.29.100
Run-time dependency libavcodec found: YES 58.54.100
Run-time dependency libavutil found: YES 56.31.100
Run-time dependency libswresample found: YES 3.5.100
Run-time dependency sdl2 found: YES 2.0.10
Run-time dependency libavdevice found: YES 58.8.100
Run-time dependency libusb-1.0 found: YES 1.0.28
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 \