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

@ -110,7 +110,7 @@ _scrcpy() {
case "$prev" in
--video-codec)
COMPREPLY=($(compgen -W 'h264 h265 av1' -- "$cur"))
COMPREPLY=($(compgen -W 'h264 h265 av1 vp8 vp9' -- "$cur"))
return
;;
--audio-codec)

View file

@ -97,7 +97,7 @@ arguments=(
{-v,--version}'[Print the version of scrcpy]'
{-V,--verbosity=}'[Set the log level]:verbosity:(verbose debug info warn error)'
'--video-buffer=[Add a buffering delay \(in milliseconds\) before displaying video frames]'
'--video-codec=[Select the video codec]:codec:(h264 h265 av1)'
'--video-codec=[Select the video codec]:codec:(h264 h265 av1 vp8 vp9)'
'--video-codec-options=[Set a list of comma-separated key\:type=value options for the device video encoder]'
'--video-encoder=[Use a specific MediaCodec video encoder]'
'--video-source=[Select the video source]:source:(display camera)'

View file

@ -604,7 +604,7 @@ Default is 0 (no buffering).
.TP
.BI "\-\-video\-codec " name
Select a video codec (h264, h265 or av1).
Select a video codec (h264, h265, av1, vp8 or vp9).
Default is h264.

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:

View file

@ -9,7 +9,9 @@ public enum VideoCodec implements Codec {
H264(0x68_32_36_34, "h264", MediaFormat.MIMETYPE_VIDEO_AVC),
H265(0x68_32_36_35, "h265", MediaFormat.MIMETYPE_VIDEO_HEVC),
@SuppressLint("InlinedApi") // introduced in API 29
AV1(0x00_61_76_31, "av1", MediaFormat.MIMETYPE_VIDEO_AV1);
AV1(0x00_61_76_31, "av1", MediaFormat.MIMETYPE_VIDEO_AV1),
VP8(0x00_76_70_38, "vp8", MediaFormat.MIMETYPE_VIDEO_VP8),
VP9(0x00_76_70_39, "vp9", MediaFormat.MIMETYPE_VIDEO_VP9);
private final int id; // 4-byte ASCII representation of the name
private final String name;