Ubuntu20.04版本上安装最新版本的scrcpy工具

前言:我本地使用的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 filename%3Dscrcpy-server-v3.3.4\&response-content-type=application%2Foctet-stream following

--2026-01-06 17:15:32-- 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 filename%3Dscrcpy-server-v3.3.4\&response-content-type=application%2Foctet-stream

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 <sys/socket.h> has symbol "SOCK_CLOEXEC" : YES

Configuring config.h using configuration

Build targets in project: 2

Found ninja-1.10.0 at /usr/bin/ninja

76/76 Linking target app/scrcpy.

scrcpy Installing (sudo)...

0/1 Installing files.
Installing app/scrcpy to /usr/local/bin
Stripping target 'app/scrcpy' using strip.
Installing server/scrcpy-server to /usr/local/share/scrcpy
Installing /home/your/workspace/tools/myscrcpy/scrcpy/app/scrcpy.1 to /usr/local/share/man/man1
Installing /home/your/workspace/tools/myscrcpy/scrcpy/app/data/icon.png to /usr/local/share/icons/hicolor/256x256/apps
Installing /home/your/workspace/tools/myscrcpy/scrcpy/app/data/zsh-completion/_scrcpy to /usr/local/share/zsh/site-functions
Installing /home/your/workspace/tools/myscrcpy/scrcpy/app/data/bash-completion/scrcpy to /usr/local/share/bash-completion/completions
Installing /home/your/workspace/tools/myscrcpy/scrcpy/app/data/scrcpy.desktop to /usr/local/share/applications
Installing /home/your/workspace/tools/myscrcpy/scrcpy/app/data/scrcpy-console.desktop to /usr/local/share/applications

完结,撒花✿✿ヽ(°▽°)ノ✿

相关推荐
故渊at18 小时前
系列三:组件化与模块化进阶 | 第11篇 组件化项目规范与问题根治:依赖、资源、Manifest 与混淆的全链路管控
android·架构·mvvm·模块化·组件化
故渊at18 小时前
系列二:MVVM 深度实战与项目重构 | 第7篇 LiveData & StateFlow 状态管理实战:从“粘包弹”到“丝滑流式”
android·重构
是阿建吖!18 小时前
【Linux】信号
android·linux·c语言·c++
alexhilton20 小时前
AppFunctions:让你的Android应用更容易被AI智能体发现
android·kotlin·android jetpack
qq36219670520 小时前
APK文件签名校验教程:验证APK真伪的完整方法
android·智能手机
赏金术士20 小时前
Android 组件化概念和特征
android·kotlin·组件化
2501_915909061 天前
深入解析Mock.js:功能、应用及实战案例,提升前端开发效率
android·ios·小程序·https·uni-app·iphone·webview
风吹夏回1 天前
TypeScript 快速上手指南:从 JavaScript 到类型安全
javascript·ubuntu·typescript
流星白龙1 天前
【MySQL高阶】21.撤销表空间,撤销日志
android·mysql·adb