Skip to content

Display and control your Android device

Add support for VP8 and VP9 video encoders

pngocthach8ced13253851
diff --git a/app/data/bash-completion/scrcpy b/app/data/bash-completion/scrcpy
index 80551d77..53ab5edc 100644
--- a/app/data/bash-completion/scrcpy
+++ b/app/data/bash-completion/scrcpy
@@ -118,7 +118,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)
diff --git a/app/data/zsh-completion/_scrcpy b/app/data/zsh-completion/_scrcpy
index e5986af7..4c6688d4 100644
--- a/app/data/zsh-completion/_scrcpy
+++ b/app/data/zsh-completion/_scrcpy
@@ -105,7 +105,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)'
diff --git a/app/deps/ffmpeg.sh b/app/deps/ffmpeg.sh
index 76a570a8..6a4f72f9 100755
--- a/app/deps/ffmpeg.sh
+++ b/app/deps/ffmpeg.sh
@@ -63,6 +63,8 @@ else
--enable-decoder=h264
--enable-decoder=hevc
--enable-decoder=av1
+ --enable-decoder=vp8
+ --enable-decoder=vp9
--enable-decoder=libdav1d
--enable-decoder=pcm_s16le
--enable-decoder=opus
diff --git a/app/scrcpy.1 b/app/scrcpy.1
index 644206cb..d6d33a5b 100644
--- a/app/scrcpy.1
+++ b/app/scrcpy.1
@@ -652,7 +652,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.
diff --git a/app/src/cli.c b/app/src/cli.c
index 785e8b9f..dee788fc 100644
--- a/app/src/cli.c
+++ b/app/src/cli.c
@@ -968,7 +968,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.",
},
{
@@ -2016,7 +2016,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;
}
diff --git a/app/src/demuxer.c b/app/src/demuxer.c
index 6d3ae14b..88025d0d 100644
--- a/app/src/demuxer.c
+++ b/app/src/demuxer.c
@@ -21,6 +21,8 @@ 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_AV1 UINT32_C(0x00617631) // "av1" 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_OPUS UINT32_C(0x6f707573) // "opus" in ASCII
#define SC_CODEC_ID_AAC UINT32_C(0x00616163) // "aac" in ASCII
#define SC_CODEC_ID_FLAC UINT32_C(0x666c6163) // "flac" in ASCII
@@ -37,6 +39,10 @@ sc_demuxer_to_avcodec_id(uint32_t codec_id) {
LOGE("AV1 not supported by this FFmpeg version");
return AV_CODEC_ID_NONE;
#endif
+ case SC_CODEC_ID_VP8:
+ return AV_CODEC_ID_VP8;
+ case SC_CODEC_ID_VP9:
+ return AV_CODEC_ID_VP9;
case SC_CODEC_ID_OPUS:
return AV_CODEC_ID_OPUS;
case SC_CODEC_ID_AAC:
diff --git a/app/src/options.h b/app/src/options.h
index cf4b2fbe..9a461d8b 100644
--- a/app/src/options.h
+++ b/app/src/options.h
@@ -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,
diff --git a/app/src/server.c b/app/src/server.c
index a6e33c09..4f95b85e 100644
--- a/app/src/server.c
+++ b/app/src/server.c
@@ -111,6 +111,10 @@ sc_server_get_codec_name(enum sc_codec codec) {
return "h265";
case SC_CODEC_AV1:
return "av1";
+ case SC_CODEC_VP8:
+ return "vp8";
+ case SC_CODEC_VP9:
+ return "vp9";
case SC_CODEC_OPUS:
return "opus";
case SC_CODEC_AAC:
diff --git a/doc/develop.md b/doc/develop.md
index 6fe48c4b..c89a3e7f 100644
--- a/doc/develop.md
+++ b/doc/develop.md
@@ -356,6 +356,8 @@ Valid codec ids for _video_ streams are:
- `"h264"` (`0x68323634`)
- `"h265"` (`0x68323635`)
- `"av1"` (`0x00617631`)
+ - `"vp8"` (`0x00767038`)
+ - `"vp9"` (`0x00767039`)
Valid codec ids for _audio_ streams are:
- `"opus"` (`0x6F707573`)
diff --git a/server/src/main/java/com/genymobile/scrcpy/video/VideoCodec.java b/server/src/main/java/com/genymobile/scrcpy/video/VideoCodec.java
index 5f19603d..8b9de0ff 100644
--- a/server/src/main/java/com/genymobile/scrcpy/video/VideoCodec.java
+++ b/server/src/main/java/com/genymobile/scrcpy/video/VideoCodec.java
@@ -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;