ref: f47f32baa441886ef7f640236e30d609f678aa4f
parent: b03ff456fb60014ecc313a21d8fde7a39505c08a
author: knik <[email protected]>
date: Tue Jul 18 09:58:19 EDT 2017
added quiet mode
--- a/frontend/main.c
+++ b/frontend/main.c
@@ -77,6 +77,8 @@
#define FALSE 0
#define TRUE 1
+#define fprintf if(!silent)fprintf
+
const char *usage =
"Usage: %s [options] [-o outfile] infiles ...\n"
"\n"
@@ -94,6 +96,7 @@
" -b <bitrate>\tSet average bitrate to x kbps. (ABR, lower quality mode)\n"
" -c <freq>\tSet the bandwidth in Hz. (default=automatic)\n"
" -o X\t\tSet output file to X (only for one input file)\n"
+ " -s\t\tquiet mode\n"
" -r\t\tUse RAW AAC output file.\n"
" -P\t\tRaw PCM input mode (default 44100Hz 16bit stereo).\n"
" -R\t\tRaw PCM input rate.\n"
@@ -149,6 +152,7 @@
"\t\tonly for one input file; you can use *.aac, *.mp4, *.m4a or\n"
"\t\t*.m4b as file extension, and the file format will be set\n"
"\t\tautomatically to ADTS or MP4).\n"
+ " -s\t\tquiet mode\n\t\tdisable all printed messages\n"
" -P\t\tRaw PCM input mode (default: off, i.e. expecting a WAV header;\n"
"\t\tnecessary for input files or bitstreams without a header; using\n"
"\t\tonly -P assumes the default values for -R, -B and -C in the\n"
@@ -433,6 +437,7 @@
char *faac_id_string;
char *faac_copyright_string;
int ignorelen = FALSE;
+ int silent = FALSE;
#ifndef _WIN32
// install signal handler
@@ -440,19 +445,6 @@
signal(SIGTERM, signal_handler);
#endif
- // get faac version
- if (faacEncGetVersion(&faac_id_string, &faac_copyright_string) ==
- FAAC_CFG_VERSION)
- {
- fprintf(stderr, "Freeware Advanced Audio Coder\nFAAC %s\n\n",
- faac_id_string);
- }
- else
- {
- fprintf(stderr, __FILE__ "(%d): wrong libfaac version\n", __LINE__);
- return 1;
- }
-
/* begin process command line */
progName = argv[0];
while (1)
@@ -493,7 +485,7 @@
int c = -1;
int option_index = 0;
- c = getopt_long(argc, argv, "Hhb:m:o:rnc:q:PR:B:C:I:Xw",
+ c = getopt_long(argc, argv, "Hhb:m:o:rnc:q:PR:B:C:I:Xws",
long_options, &option_index);
if (c == -1)
@@ -714,6 +706,9 @@
case 'X':
rawEndian = 0;
break;
+ case 's':
+ silent = TRUE;
+ break;
case 'H':
dieMessage = long_help;
break;
@@ -727,6 +722,19 @@
}
}
+ // get faac version
+ if (faacEncGetVersion(&faac_id_string, &faac_copyright_string) ==
+ FAAC_CFG_VERSION)
+ {
+ fprintf(stderr, "Freeware Advanced Audio Coder\nFAAC %s\n\n",
+ faac_id_string);
+ }
+ else
+ {
+ fprintf(stderr, __FILE__ "(%d): wrong libfaac version\n", __LINE__);
+ return 1;
+ }
+
/* check that we have at least one non-option arguments */
if (!dieMessage && (argc - optind) > 1 && aacFileNameGiven)
dieMessage =
@@ -967,10 +975,14 @@
fprintf(stderr, "Encoding %s to %s\n", audioFileName, aacFileName);
if (frames != 0)
+ {
fprintf(stderr, " frame | bitrate | elapsed/estim | "
"play/CPU | ETA\n");
+ }
else
+ {
fprintf(stderr, " frame | elapsed | play/CPU\n");
+ }
/* encoding loop */
#ifdef _WIN32
@@ -1039,6 +1051,7 @@
showcnt += 50;
if (frames != 0)
+ {
fprintf(stderr,
"\r%5d/%-5d (%3d%%)| %5.1f | %6.1f/%-6.1f | %7.2fx | %.1f ",
currentFrame, frames, currentFrame * 100 / frames,
@@ -1050,7 +1063,9 @@
timeused,
timeused * (frames -
currentFrame) / currentFrame);
+ }
else
+ {
fprintf(stderr,
"\r %5d | %6.1f | %7.2fx ",
currentFrame,
@@ -1057,6 +1072,7 @@
timeused,
(1024.0 * currentFrame / infile->samplerate) /
timeused);
+ }
fflush(stderr);
#ifdef _WIN32