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:
parent
3e517cd40e
commit
4342c5637d
7 changed files with 19 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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[,...]
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -25,6 +25,7 @@ enum sc_record_format {
|
|||
|
||||
enum sc_codec {
|
||||
SC_CODEC_H264,
|
||||
SC_CODEC_H265,
|
||||
};
|
||||
|
||||
enum sc_lock_video_orientation {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue