static int CheckOptions( int argc, char ** argv );
static int HandleEvents( hb_handle_t * h );
+/****************************************************************************
+ * hb_error_handler
+ *
+ * When using the CLI just display using hb_log as we always did in the past
+ * make sure that we prefix with a nice ERROR message to catch peoples eyes.
+ ****************************************************************************/
+static void hb_cli_error_handler ( const char *errmsg )
+{
+ fprintf( stderr, "ERROR: %s", errmsg );
+}
+
int main( int argc, char ** argv )
{
hb_handle_t * h;
return 1;
}
+ /* Register our error handler */
+ hb_register_error_handler(&hb_cli_error_handler);
+
/* Init libhb */
h = hb_init( debug, update );
job->maxWidth = maxWidth;
if (maxHeight)
job->maxHeight = maxHeight;
-
+
if( subtitle_force )
{
job->subtitle_force = subtitle_force;
- }
-
+ }
+
+ if( subtitle_scan )
+ {
+ char *x264opts_tmp;
+
+ /*
+ * When subtitle scan is enabled do a fast pre-scan job
+ * which will determine which subtitles to enable, if any.
+ */
+ job->pass = -1;
+
+ x264opts_tmp = job->x264opts;
+
+ job->x264opts = NULL;
+
+ job->indepth_scan = subtitle_scan;
+ fprintf( stderr, "Subtitle Scan Enabled - enabling "
+ "subtitles if found for foreign language segments\n");
+ job->select_subtitle = malloc(sizeof(hb_subtitle_t*));
+ *(job->select_subtitle) = NULL;
+
+ /*
+ * Add the pre-scan job
+ */
+ hb_add( h, job );
+
+ job->x264opts = x264opts_tmp;
+ }
+
if( twoPass )
{
/*
* for the first pass and then off again for the
* second.
*/
+ hb_subtitle_t **subtitle_tmp = job->select_subtitle;
+
+ job->select_subtitle = NULL;
+
job->pass = 1;
- job->subtitle_scan = subtitle_scan;
- if( subtitle_scan )
- {
- fprintf( stderr, "Subtitle Scan Enabled - enabling "
- "subtitles if found for foreign language segments\n");
- job->select_subtitle = malloc(sizeof(hb_subtitle_t*));
- *(job->select_subtitle) = NULL;
- }
+
+ job->indepth_scan = 0;
/*
* If turbo options have been selected then append them
job->x264opts = x264opts;
}
hb_add( h, job );
+
+ job->select_subtitle = subtitle_tmp;
+
job->pass = 2;
/*
* On the second pass we turn off subtitle scan so that we
* selected in the first pass (using the whacky select-subtitle
* attribute of the job).
*/
- job->subtitle_scan = 0;
+ job->indepth_scan = 0;
job->x264opts = x264opts2;
/*
* Turn on subtitle scan if requested, note that this option
* precludes encoding of any actual subtitles.
- */
- if ( subtitle_scan )
- {
- fprintf( stderr, "Warning: Subtitle Scan only works in two-pass, disabling\n");
- }
+ */
+
+ job->indepth_scan = 0;
job->pass = 0;
hb_add( h, job );
}
" -Y, --maxHeight <#> Set maximum height\n"
" -X, --maxWidth <#> Set maximum width\n"
" -s, --subtitle <number> Select subtitle (default: none)\n"
- " -U, --subtitle-scan Scan for subtitles on the first pass, and choose\n"
+ " -U, --subtitle-scan Scan for subtitles in an extra first pass, and choose\n"
" the one that's only used 10 percent of the time\n"
" or less. This should locate subtitles for short\n"
- " foreign language segments. Only works with 2-pass.\n"
- " -F, --subtitle-force Only display subtitles from the selected stream if\n"
- " the subtitles have the forced flag set.\n"
+ " foreign language segments. Best used in conjunction\n"
+ " with --subtitle-forced.\n"
+ " -F, --subtitle-forced Only display subtitles from the selected stream if\n"
+ " the subtitle has the forced flag set. May be used in\n"
+ " conjunction with --subtitle-scan to auto-select\n"
+ " a stream if it contains forced subtitles.\n"
" -N, --native-language Select subtitles with this language if it does not\n"
" <string> match the Audio language. Provide the language's\n"
" iso639-2 code (fre, eng, spa, dut, et cetera)\n"
return 0;
}
-