Add support for H265

Add option --codec=h265.

PR #3713 <https://github.com/Genymobile/scrcpy/pull/3713>
Fixes #3092 <https://github.com/Genymobile/scrcpy/issues/3092>
This commit is contained in:
Romain Vimont
2023-02-03 12:40:55 +01:00
parent 3e517cd40e
commit 4342c5637d
7 changed files with 19 additions and 6 deletions

View File

@@ -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[,...]

View File

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

View File

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

View File

@@ -25,6 +25,7 @@ enum sc_record_format {
enum sc_codec {
SC_CODEC_H264,
SC_CODEC_H265,
};
enum sc_lock_video_orientation {

View File

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