Skip to content

Display and control your Android device

Add support for H265

Romain Vimont4342c5637d74
diff --git a/README.md b/README.md
index facdfc81..6218bee4 100644
--- a/README.md
+++ b/README.md
@@ -254,10 +254,12 @@ The [window may also be rotated](#rotation) independently.
#### Codec
-The video codec can be selected:
+The video codec can be selected. The possible values are `h264` (default) and
+`h265`:
```bash
scrcpy --codec=h264 # default
+scrcpy --codec=h265
```
@@ -275,7 +277,7 @@ error will give the available encoders:
```bash
scrcpy --encoder=_ # for the default codec
-scrcpy --codec=h264 --encoder=_ # for a specific codec
+scrcpy --codec=h265 --encoder=_ # for a specific codec
```
### Capture
diff --git a/app/scrcpy.1 b/app/scrcpy.1
index c7ddeefb..be607173 100644
--- a/app/scrcpy.1
+++ b/app/scrcpy.1
@@ -27,7 +27,7 @@ Default is 8000000.
.TP
.BI "\-\-codec " name
-Select a video codec (h264).
+Select a video codec (h264 or h265).
.TP
.BI "\-\-codec\-options " key\fR[:\fItype\fR]=\fIvalue\fR[,...]
diff --git a/app/src/cli.c b/app/src/cli.c
index ee65e4c0..76d59f38 100644
--- a/app/src/cli.c
+++ b/app/src/cli.c
@@ -110,7 +110,7 @@ static const struct sc_option options[] = {
.longopt_id = OPT_CODEC,
.longopt = "codec",
.argdesc = "name",
- .text = "Select a video codec (h264).",
+ .text = "Select a video codec (h264 or h265).",
},
{
.longopt_id = OPT_CODEC_OPTIONS,
@@ -1390,7 +1390,11 @@ parse_codec(const char *optarg, enum sc_codec *codec) {
*codec = SC_CODEC_H264;
return true;
}
- LOGE("Unsupported codec: %s (expected h264)", optarg);
+ if (!strcmp(optarg, "h265")) {
+ *codec = SC_CODEC_H265;
+ return true;
+ }
+ LOGE("Unsupported codec: %s (expected h264 or h265)", optarg);
return false;
}
diff --git a/app/src/demuxer.c b/app/src/demuxer.c
index ad0b40a2..119d4065 100644
--- a/app/src/demuxer.c
+++ b/app/src/demuxer.c
@@ -26,10 +26,13 @@ sc_demuxer_recv_codec_id(struct sc_demuxer *demuxer) {
}
#define SC_CODEC_ID_H264 UINT32_C(0x68323634) // "h264" in ASCII
+#define SC_CODEC_ID_H265 UINT32_C(0x68323635) // "h265" in ASCII
uint32_t codec_id = sc_read32be(data);
switch (codec_id) {
case SC_CODEC_ID_H264:
return AV_CODEC_ID_H264;
+ case SC_CODEC_ID_H265:
+ return AV_CODEC_ID_HEVC;
default:
LOGE("Unknown codec id 0x%08" PRIx32, codec_id);
return AV_CODEC_ID_NONE;
diff --git a/app/src/options.h b/app/src/options.h
index 18006e42..b3c39594 100644
--- a/app/src/options.h
+++ b/app/src/options.h
@@ -25,6 +25,7 @@ enum sc_record_format {
enum sc_codec {
SC_CODEC_H264,
+ SC_CODEC_H265,
};
enum sc_lock_video_orientation {
diff --git a/app/src/server.c b/app/src/server.c
index aaa0ffb1..a63504bb 100644
--- a/app/src/server.c
+++ b/app/src/server.c
@@ -161,6 +161,8 @@ sc_server_get_codec_name(enum sc_codec codec) {
switch (codec) {
case SC_CODEC_H264:
return "h264";
+ case SC_CODEC_H265:
+ return "h265";
default:
return NULL;
}
diff --git a/server/src/main/java/com/genymobile/scrcpy/VideoCodec.java b/server/src/main/java/com/genymobile/scrcpy/VideoCodec.java
index e5edfcf2..048765f7 100644
--- a/server/src/main/java/com/genymobile/scrcpy/VideoCodec.java
+++ b/server/src/main/java/com/genymobile/scrcpy/VideoCodec.java
@@ -3,7 +3,8 @@ package com.genymobile.scrcpy;
import android.media.MediaFormat;
public enum VideoCodec {
- H264(0x68_32_36_34, "h264", MediaFormat.MIMETYPE_VIDEO_AVC);
+ H264(0x68_32_36_34, "h264", MediaFormat.MIMETYPE_VIDEO_AVC),
+ H265(0x68_32_36_35, "h265", MediaFormat.MIMETYPE_VIDEO_HEVC);
private final int id; // 4-byte ASCII representation of the name
private final String name;