Rename --output-file to --record

To record the screen to a local file:

    scrcpy --record file.mp4
This commit is contained in:
Romain Vimont 2018-11-11 14:03:29 +01:00
parent 70579dc709
commit 22bf0c19d6
3 changed files with 15 additions and 14 deletions

View file

@ -11,7 +11,7 @@
struct args { struct args {
const char *serial; const char *serial;
const char *crop; const char *crop;
const char *out_filename; const char *record_filename;
SDL_bool fullscreen; SDL_bool fullscreen;
SDL_bool help; SDL_bool help;
SDL_bool version; SDL_bool version;
@ -50,13 +50,13 @@ static void usage(const char *arg0) {
" is preserved.\n" " is preserved.\n"
" Default is %d%s.\n" " Default is %d%s.\n"
"\n" "\n"
" -o, --output-file\n"
" Write video output to file.\n"
"\n"
" -p, --port port\n" " -p, --port port\n"
" Set the TCP port the client listens on.\n" " Set the TCP port the client listens on.\n"
" Default is %d.\n" " Default is %d.\n"
"\n" "\n"
" -r, --record file.mp4\n"
" Record screen to file.\n"
"\n"
" -s, --serial\n" " -s, --serial\n"
" The device serial number. Mandatory only if several devices\n" " The device serial number. Mandatory only if several devices\n"
" are connected to adb.\n" " are connected to adb.\n"
@ -211,15 +211,15 @@ static SDL_bool parse_args(struct args *args, int argc, char *argv[]) {
{"fullscreen", no_argument, NULL, 'f'}, {"fullscreen", no_argument, NULL, 'f'},
{"help", no_argument, NULL, 'h'}, {"help", no_argument, NULL, 'h'},
{"max-size", required_argument, NULL, 'm'}, {"max-size", required_argument, NULL, 'm'},
{"output-file", required_argument, NULL, 'o'},
{"port", required_argument, NULL, 'p'}, {"port", required_argument, NULL, 'p'},
{"record", required_argument, NULL, 'r'},
{"serial", required_argument, NULL, 's'}, {"serial", required_argument, NULL, 's'},
{"show-touches", no_argument, NULL, 't'}, {"show-touches", no_argument, NULL, 't'},
{"version", no_argument, NULL, 'v'}, {"version", no_argument, NULL, 'v'},
{NULL, 0, NULL, 0 }, {NULL, 0, NULL, 0 },
}; };
int c; int c;
while ((c = getopt_long(argc, argv, "b:c:fhm:o:p:s:tv", long_options, NULL)) != -1) { while ((c = getopt_long(argc, argv, "b:c:fhm:p:r:s:tv", long_options, NULL)) != -1) {
switch (c) { switch (c) {
case 'b': case 'b':
if (!parse_bit_rate(optarg, &args->bit_rate)) { if (!parse_bit_rate(optarg, &args->bit_rate)) {
@ -240,14 +240,14 @@ static SDL_bool parse_args(struct args *args, int argc, char *argv[]) {
return SDL_FALSE; return SDL_FALSE;
} }
break; break;
case 'o':
args->out_filename = optarg;
break;
case 'p': case 'p':
if (!parse_port(optarg, &args->port)) { if (!parse_port(optarg, &args->port)) {
return SDL_FALSE; return SDL_FALSE;
} }
break; break;
case 'r':
args->record_filename = optarg;
break;
case 's': case 's':
args->serial = optarg; args->serial = optarg;
break; break;
@ -281,6 +281,7 @@ int main(int argc, char *argv[]) {
struct args args = { struct args args = {
.serial = NULL, .serial = NULL,
.crop = NULL, .crop = NULL,
.record_filename = NULL,
.help = SDL_FALSE, .help = SDL_FALSE,
.version = SDL_FALSE, .version = SDL_FALSE,
.show_touches = SDL_FALSE, .show_touches = SDL_FALSE,
@ -318,7 +319,7 @@ int main(int argc, char *argv[]) {
.serial = args.serial, .serial = args.serial,
.crop = args.crop, .crop = args.crop,
.port = args.port, .port = args.port,
.out_filename = args.out_filename, .record_filename = args.record_filename,
.max_size = args.max_size, .max_size = args.max_size,
.bit_rate = args.bit_rate, .bit_rate = args.bit_rate,
.show_touches = args.show_touches, .show_touches = args.show_touches,

View file

@ -192,8 +192,8 @@ SDL_bool scrcpy(const struct scrcpy_options *options) {
} }
struct recorder *rec = NULL; struct recorder *rec = NULL;
if (options->out_filename) { if (options->record_filename) {
if (!recorder_init(&recorder, options->out_filename, frame_size)) { if (!recorder_init(&recorder, options->record_filename, frame_size)) {
ret = SDL_FALSE; ret = SDL_FALSE;
server_stop(&server); server_stop(&server);
goto finally_destroy_file_handler; goto finally_destroy_file_handler;
@ -255,7 +255,7 @@ finally_destroy_file_handler:
file_handler_join(&file_handler); file_handler_join(&file_handler);
file_handler_destroy(&file_handler); file_handler_destroy(&file_handler);
finally_destroy_recorder: finally_destroy_recorder:
if (options->out_filename) { if (options->record_filename) {
recorder_destroy(&recorder); recorder_destroy(&recorder);
} }
finally_destroy_frames: finally_destroy_frames:

View file

@ -6,7 +6,7 @@
struct scrcpy_options { struct scrcpy_options {
const char *serial; const char *serial;
const char *crop; const char *crop;
const char *out_filename; const char *record_filename;
Uint16 port; Uint16 port;
Uint16 max_size; Uint16 max_size;
Uint32 bit_rate; Uint32 bit_rate;