diff --git a/app/data/bash-completion/scrcpy b/app/data/bash-completion/scrcpy index 74c3ee57de..39c861f13b 100644 --- a/app/data/bash-completion/scrcpy +++ b/app/data/bash-completion/scrcpy @@ -78,7 +78,7 @@ _scrcpy() { return ;; --audio-codec) - COMPREPLY=($(compgen -W 'opus aac' -- "$cur")) + COMPREPLY=($(compgen -W 'raw opus aac' -- "$cur")) return ;; --lock-video-orientation) diff --git a/app/data/zsh-completion/_scrcpy b/app/data/zsh-completion/_scrcpy index b28201a4d3..d5c837c64c 100644 --- a/app/data/zsh-completion/_scrcpy +++ b/app/data/zsh-completion/_scrcpy @@ -10,7 +10,7 @@ local arguments arguments=( '--always-on-top[Make scrcpy window always on top \(above other windows\)]' '--audio-bit-rate=[Encode the audio at the given bit-rate]' - '--audio-codec=[Select the audio codec]:codec:(opus aac)' + '--audio-codec=[Select the audio codec]:codec:(raw opus aac)' '--audio-codec-options=[Set a list of comma-separated key\:type=value options for the device audio encoder]' '--audio-encoder=[Use a specific MediaCodec audio encoder]' {-b,--video-bit-rate=}'[Encode the video at the given bit-rate]' diff --git a/app/scrcpy.1 b/app/scrcpy.1 index 2e1775ca51..dec5896531 100644 --- a/app/scrcpy.1 +++ b/app/scrcpy.1 @@ -33,7 +33,7 @@ Default is 0 (no buffering). .TP .BI "\-\-audio\-codec " name -Select an audio codec (opus or aac). +Select an audio codec (raw, opus or aac). Default is opus. diff --git a/app/src/cli.c b/app/src/cli.c index fd76c097ac..195da15422 100644 --- a/app/src/cli.c +++ b/app/src/cli.c @@ -132,7 +132,7 @@ static const struct sc_option options[] = { .longopt_id = OPT_AUDIO_CODEC, .longopt = "audio-codec", .argdesc = "name", - .text = "Select an audio codec (opus or aac).\n" + .text = "Select an audio codec (raw, opus or aac).\n" "Default is opus.", }, { @@ -1506,6 +1506,10 @@ parse_video_codec(const char *optarg, enum sc_codec *codec) { static bool parse_audio_codec(const char *optarg, enum sc_codec *codec) { + if (!strcmp(optarg, "raw")) { + *codec = SC_CODEC_RAW; + return true; + } if (!strcmp(optarg, "opus")) { *codec = SC_CODEC_OPUS; return true; @@ -1514,7 +1518,7 @@ parse_audio_codec(const char *optarg, enum sc_codec *codec) { *codec = SC_CODEC_AAC; return true; } - LOGE("Unsupported audio codec: %s (expected opus or aac)", optarg); + LOGE("Unsupported audio codec: %s (expected raw, opus or aac)", optarg); return false; } @@ -1912,6 +1916,12 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[], } } + if (opts->record_filename && opts->audio_codec == SC_CODEC_RAW) { + LOGW("Recording does not support RAW audio codec, automatically " + "switching to --audio-codec=opus"); + opts->audio_codec = SC_CODEC_OPUS; + } + if (!opts->control) { if (opts->turn_screen_off) { LOGE("Could not request to turn screen off if control is disabled"); diff --git a/app/src/demuxer.c b/app/src/demuxer.c index 6d3530d9a2..9fa38f6247 100644 --- a/app/src/demuxer.c +++ b/app/src/demuxer.c @@ -23,6 +23,7 @@ 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_RAW UINT32_C(0x00726177) // "raw" in ASCII #define SC_CODEC_ID_OPUS UINT32_C(0x6f707573) // "opus" in ASCII #define SC_CODEC_ID_AAC UINT32_C(0x00616163) // "aac in ASCII" switch (codec_id) { @@ -32,6 +33,8 @@ sc_demuxer_to_avcodec_id(uint32_t codec_id) { return AV_CODEC_ID_HEVC; case SC_CODEC_ID_AV1: return AV_CODEC_ID_AV1; + case SC_CODEC_ID_RAW: + return AV_CODEC_ID_PCM_S16LE; 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 d9c2d22812..4acd4c2599 100644 --- a/app/src/options.h +++ b/app/src/options.h @@ -27,6 +27,7 @@ enum sc_codec { SC_CODEC_H264, SC_CODEC_H265, SC_CODEC_AV1, + SC_CODEC_RAW, SC_CODEC_OPUS, SC_CODEC_AAC, }; diff --git a/app/src/server.c b/app/src/server.c index 9d4fb098a7..a26ae71de0 100644 --- a/app/src/server.c +++ b/app/src/server.c @@ -169,6 +169,8 @@ sc_server_get_codec_name(enum sc_codec codec) { return "h265"; case SC_CODEC_AV1: return "av1"; + case SC_CODEC_RAW: + return "raw"; case SC_CODEC_OPUS: return "opus"; case SC_CODEC_AAC: