diff --git a/src/cmd/fpcalc.cpp b/src/cmd/fpcalc.cpp index d75ecca..cf6999a 100644 --- a/src/cmd/fpcalc.cpp +++ b/src/cmd/fpcalc.cpp @@ -28,6 +28,7 @@ static double g_max_chunk_duration = 0; static bool g_overlap = false; static bool g_raw = false; static bool g_abs_ts = false; +static bool ignore_errors = false; const char *g_help = "Usage: %s [OPTIONS] FILE [FILE...]\n" @@ -47,6 +48,7 @@ const char *g_help = " -text Print the output in text format\n" " -plain Print the just the fingerprint in text format\n" " -version Print version information\n" + " -ignore-errors Ignore some errors in order to output fingerprints anyway - helpful with buggy live streams\n" ; static void ParseOptions(int &argc, char **argv) { @@ -56,6 +58,8 @@ static void ParseOptions(int &argc, char **argv) { while (++i < argc) { argv[j++] = argv[i]; } + } else if ((!strcmp(argv[i], "-ignore-errors") || !strcmp(argv[i], "-i")) && i + 1 < argc) { + ignore_errors = true; } else if ((!strcmp(argv[i], "-format") || !strcmp(argv[i], "-f")) && i + 1 < argc) { g_input_format = argv[++i]; } else if ((!strcmp(argv[i], "-channels") || !strcmp(argv[i], "-c")) && i + 1 < argc) { @@ -261,6 +265,8 @@ void ProcessFile(ChromaprintContext *ctx, FFmpegAudioReader &reader, const char size_t frame_size = 0; if (!reader.Read(&frame_data, &frame_size)) { fprintf(stderr, "ERROR: %s\n", reader.GetError().c_str()); + if (ignore_errors) + break; exit(2); } @@ -354,7 +360,8 @@ void ProcessFile(ChromaprintContext *ctx, FFmpegAudioReader &reader, const char if (!chromaprint_finish(ctx)) { fprintf(stderr, "ERROR: Could not finish the fingerprinting process\n"); - exit(2); + if (!ignore_errors) + exit(2); } if (chunk_size > 0) {