mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-08-01 13:48:58 +00:00
Add support for AV1
Add option --codec=av1. PR #3713 <https://github.com/Genymobile/scrcpy/pull/3713>
This commit is contained in:
parent
4342c5637d
commit
d2dce51038
7 changed files with 25 additions and 6 deletions
|
@ -27,7 +27,7 @@ Default is 8000000.
|
|||
|
||||
.TP
|
||||
.BI "\-\-codec " name
|
||||
Select a video codec (h264 or h265).
|
||||
Select a video codec (h264, h265 or av1).
|
||||
|
||||
.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 or h265).",
|
||||
.text = "Select a video codec (h264, h265 or av1).",
|
||||
},
|
||||
{
|
||||
.longopt_id = OPT_CODEC_OPTIONS,
|
||||
|
@ -1394,7 +1394,11 @@ parse_codec(const char *optarg, enum sc_codec *codec) {
|
|||
*codec = SC_CODEC_H265;
|
||||
return true;
|
||||
}
|
||||
LOGE("Unsupported codec: %s (expected h264 or h265)", optarg);
|
||||
if (!strcmp(optarg, "av1")) {
|
||||
*codec = SC_CODEC_AV1;
|
||||
return true;
|
||||
}
|
||||
LOGE("Unsupported codec: %s (expected h264, h265 or av1)", optarg);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1744,6 +1748,13 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
|
|||
}
|
||||
}
|
||||
|
||||
if (opts->record_format == SC_RECORD_FORMAT_MP4
|
||||
&& opts->codec == SC_CODEC_AV1) {
|
||||
LOGE("Could not mux AV1 stream into MP4 container "
|
||||
"(record to mkv or select another video codec)");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!opts->control) {
|
||||
if (opts->turn_screen_off) {
|
||||
LOGE("Could not request to turn screen off if control is disabled");
|
||||
|
|
|
@ -27,12 +27,15 @@ 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
|
||||
#define SC_CODEC_ID_AV1 UINT32_C(0x00617631) // "av1" 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;
|
||||
case SC_CODEC_ID_AV1:
|
||||
return AV_CODEC_ID_AV1;
|
||||
default:
|
||||
LOGE("Unknown codec id 0x%08" PRIx32, codec_id);
|
||||
return AV_CODEC_ID_NONE;
|
||||
|
|
|
@ -26,6 +26,7 @@ enum sc_record_format {
|
|||
enum sc_codec {
|
||||
SC_CODEC_H264,
|
||||
SC_CODEC_H265,
|
||||
SC_CODEC_AV1,
|
||||
};
|
||||
|
||||
enum sc_lock_video_orientation {
|
||||
|
|
|
@ -163,6 +163,8 @@ sc_server_get_codec_name(enum sc_codec codec) {
|
|||
return "h264";
|
||||
case SC_CODEC_H265:
|
||||
return "h265";
|
||||
case SC_CODEC_AV1:
|
||||
return "av1";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue