Add support for VP8 and VP9 video encoders

This commit is contained in:
pngocthach 2026-04-13 23:50:50 +07:00
parent 247a37d57b
commit db882500d7
8 changed files with 28 additions and 6 deletions

View file

@ -987,7 +987,7 @@ static const struct sc_option options[] = {
.longopt_id = OPT_VIDEO_CODEC,
.longopt = "video-codec",
.argdesc = "name",
.text = "Select a video codec (h264, h265 or av1).\n"
.text = "Select a video codec (h264, h265, av1, vp8 or vp9).\n"
"Default is h264.",
},
{
@ -1994,7 +1994,15 @@ parse_video_codec(const char *optarg, enum sc_codec *codec) {
*codec = SC_CODEC_AV1;
return true;
}
LOGE("Unsupported video codec: %s (expected h264, h265 or av1)", optarg);
if (!strcmp(optarg, "vp8")) {
*codec = SC_CODEC_VP8;
return true;
}
if (!strcmp(optarg, "vp9")) {
*codec = SC_CODEC_VP9;
return true;
}
LOGE("Unsupported video codec: %s (expected h264, h265, av1, vp8 or vp9)", optarg);
return false;
}

View file

@ -20,6 +20,8 @@ static enum AVCodecID
sc_demuxer_to_avcodec_id(uint32_t codec_id) {
#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_VP8 UINT32_C(0x00767038) // "vp8" in ASCII
#define SC_CODEC_ID_VP9 UINT32_C(0x00767039) // "vp9" in ASCII
#define SC_CODEC_ID_AV1 UINT32_C(0x00617631) // "av1" in ASCII
#define SC_CODEC_ID_OPUS UINT32_C(0x6f707573) // "opus" in ASCII
#define SC_CODEC_ID_AAC UINT32_C(0x00616163) // "aac" in ASCII
@ -30,6 +32,10 @@ sc_demuxer_to_avcodec_id(uint32_t codec_id) {
return AV_CODEC_ID_H264;
case SC_CODEC_ID_H265:
return AV_CODEC_ID_HEVC;
case SC_CODEC_ID_VP8:
return AV_CODEC_ID_VP8;
case SC_CODEC_ID_VP9:
return AV_CODEC_ID_VP9;
case SC_CODEC_ID_AV1:
#ifdef SCRCPY_LAVC_HAS_AV1
return AV_CODEC_ID_AV1;

View file

@ -43,6 +43,8 @@ enum sc_codec {
SC_CODEC_H264,
SC_CODEC_H265,
SC_CODEC_AV1,
SC_CODEC_VP8,
SC_CODEC_VP9,
SC_CODEC_OPUS,
SC_CODEC_AAC,
SC_CODEC_FLAC,

View file

@ -109,6 +109,10 @@ sc_server_get_codec_name(enum sc_codec codec) {
return "h264";
case SC_CODEC_H265:
return "h265";
case SC_CODEC_VP8:
return "vp8";
case SC_CODEC_VP9:
return "vp9";
case SC_CODEC_AV1:
return "av1";
case SC_CODEC_OPUS: