Accept .m4a and .mka

These are just aliases for mp4 and mkv when there is no video stream.

PR #3978 <https://github.com/Genymobile/scrcpy/pull/3978>
This commit is contained in:
Romain Vimont 2023-05-07 12:23:51 +02:00
parent 98f4f4e68a
commit d6bcde565f
3 changed files with 28 additions and 3 deletions

View file

@ -1487,6 +1487,12 @@ get_record_format(const char *name) {
if (!strcmp(name, "mkv")) {
return SC_RECORD_FORMAT_MKV;
}
if (!strcmp(name, "m4a")) {
return SC_RECORD_FORMAT_M4A;
}
if (!strcmp(name, "mka")) {
return SC_RECORD_FORMAT_MKA;
}
return 0;
}
@ -1974,6 +1980,12 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
LOGW("Recording does not support RAW audio codec");
return false;
}
if (opts->video
&& sc_record_format_is_audio_only(opts->record_format)) {
LOGE("Audio container does not support video stream");
return false;
}
}
if (opts->audio_codec == SC_CODEC_RAW) {

View file

@ -21,8 +21,16 @@ enum sc_record_format {
SC_RECORD_FORMAT_AUTO,
SC_RECORD_FORMAT_MP4,
SC_RECORD_FORMAT_MKV,
SC_RECORD_FORMAT_M4A,
SC_RECORD_FORMAT_MKA,
};
static inline bool
sc_record_format_is_audio_only(enum sc_record_format fmt) {
return fmt == SC_RECORD_FORMAT_M4A
|| fmt == SC_RECORD_FORMAT_MKA;
}
enum sc_codec {
SC_CODEC_H264,
SC_CODEC_H265,

View file

@ -60,9 +60,14 @@ sc_recorder_queue_clear(struct sc_recorder_queue *queue) {
static const char *
sc_recorder_get_format_name(enum sc_record_format format) {
switch (format) {
case SC_RECORD_FORMAT_MP4: return "mp4";
case SC_RECORD_FORMAT_MKV: return "matroska";
default: return NULL;
case SC_RECORD_FORMAT_MP4:
case SC_RECORD_FORMAT_M4A:
return "mp4";
case SC_RECORD_FORMAT_MKV:
case SC_RECORD_FORMAT_MKA:
return "matroska";
default:
return NULL;
}
}