GUAC-236: Simplify command-line options, restricting to known-good combination. Can add other formats as possible later.
This commit is contained in:
parent
ecf3a0302a
commit
710edc03ff
@ -37,26 +37,16 @@ int main(int argc, char* argv[]) {
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Load defaults */
|
/* Load defaults */
|
||||||
const char* codec = GUACENC_DEFAULT_CODEC;
|
|
||||||
const char* suffix = GUACENC_DEFAULT_SUFFIX;
|
|
||||||
int width = GUACENC_DEFAULT_WIDTH;
|
int width = GUACENC_DEFAULT_WIDTH;
|
||||||
int height = GUACENC_DEFAULT_HEIGHT;
|
int height = GUACENC_DEFAULT_HEIGHT;
|
||||||
int bitrate = GUACENC_DEFAULT_BITRATE;
|
int bitrate = GUACENC_DEFAULT_BITRATE;
|
||||||
|
|
||||||
/* Parse arguments */
|
/* Parse arguments */
|
||||||
int opt;
|
int opt;
|
||||||
while ((opt = getopt(argc, argv, "V:s:d:r:")) != -1) {
|
while ((opt = getopt(argc, argv, "s:r:")) != -1) {
|
||||||
|
|
||||||
/* -V: Video codec */
|
|
||||||
if (opt == 'V')
|
|
||||||
codec = optarg;
|
|
||||||
|
|
||||||
/* -s: Output file suffix */
|
|
||||||
else if (opt == 's')
|
|
||||||
suffix = optarg;
|
|
||||||
|
|
||||||
/* -d: Dimensions */
|
/* -d: Dimensions */
|
||||||
else if (opt == 'd') {
|
if (opt == 's') {
|
||||||
if (guacenc_parse_dimensions(optarg, &width, &height)) {
|
if (guacenc_parse_dimensions(optarg, &width, &height)) {
|
||||||
guacenc_log(GUAC_LOG_ERROR, "Invalid dimensions.");
|
guacenc_log(GUAC_LOG_ERROR, "Invalid dimensions.");
|
||||||
goto invalid_options;
|
goto invalid_options;
|
||||||
@ -97,11 +87,8 @@ int main(int argc, char* argv[]) {
|
|||||||
|
|
||||||
guacenc_log(GUAC_LOG_INFO, "%i input file(s) provided.", total_files);
|
guacenc_log(GUAC_LOG_INFO, "%i input file(s) provided.", total_files);
|
||||||
|
|
||||||
guacenc_log(GUAC_LOG_INFO, "Video will be encoded as \"%s\" at %ix%i "
|
guacenc_log(GUAC_LOG_INFO, "Video will be encoded at %ix%i "
|
||||||
"and %i bps.", codec, width, height, bitrate);
|
"and %i bps.", width, height, bitrate);
|
||||||
|
|
||||||
guacenc_log(GUAC_LOG_INFO, "Output files will end with \".%s\".", suffix);
|
|
||||||
|
|
||||||
|
|
||||||
/* Encode all input files */
|
/* Encode all input files */
|
||||||
for (i = optind; i < argc; i++) {
|
for (i = optind; i < argc; i++) {
|
||||||
@ -111,17 +98,17 @@ int main(int argc, char* argv[]) {
|
|||||||
|
|
||||||
/* Generate output filename */
|
/* Generate output filename */
|
||||||
char out_path[4096];
|
char out_path[4096];
|
||||||
int len = snprintf(out_path, sizeof(out_path), "%s.%s", path, suffix);
|
int len = snprintf(out_path, sizeof(out_path), "%s.mpg", path);
|
||||||
|
|
||||||
/* Do not write if filename exceeds maximum length */
|
/* Do not write if filename exceeds maximum length */
|
||||||
if (len >= sizeof(out_path)) {
|
if (len >= sizeof(out_path)) {
|
||||||
guacenc_log(GUAC_LOG_ERROR, "Cannot write output file \"%s.%s\": "
|
guacenc_log(GUAC_LOG_ERROR, "Cannot write output file for \"%s\": "
|
||||||
"Name too long", path, suffix);
|
"Name too long", path);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Attempt encoding, log granular success/failure at debug level */
|
/* Attempt encoding, log granular success/failure at debug level */
|
||||||
if (guacenc_encode(path, out_path, codec, width, height, bitrate)) {
|
if (guacenc_encode(path, out_path, "mpeg4", width, height, bitrate)) {
|
||||||
failures++;
|
failures++;
|
||||||
guacenc_log(GUAC_LOG_DEBUG,
|
guacenc_log(GUAC_LOG_DEBUG,
|
||||||
"%s was NOT successfully encoded.", path);
|
"%s was NOT successfully encoded.", path);
|
||||||
@ -147,10 +134,8 @@ int main(int argc, char* argv[]) {
|
|||||||
invalid_options:
|
invalid_options:
|
||||||
|
|
||||||
fprintf(stderr, "USAGE: %s"
|
fprintf(stderr, "USAGE: %s"
|
||||||
" [-d WIDTHxHEIGHT]"
|
" [-s WIDTHxHEIGHT]"
|
||||||
" [-s SUFFIX]"
|
" [-r BITRATE]\n", argv[0]);
|
||||||
" [-V CODEC]"
|
|
||||||
" [-b BITRATE]\n", argv[0]);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user